Skip to main content

Selector

Struct Selector 

Source
pub struct Selector {
    pub user: Option<String>,
    pub session: Option<String>,
    pub host: Option<String>,
    pub repo: Option<String>,
    pub worktree: Option<String>,
    pub claim: Option<String>,
    pub lead: Option<bool>,
    pub person: Option<bool>,
    pub other: Option<Value>,
}
Expand description

Picks sessions by who they are, where they work, and what they hold. Each field that is set must match. Set one or more fields.

The derive of serde is remote = "Self": it gives the read and the write of the fields of this build as functions, and the impls below add the selector other. So the tolerant reader holds this struct itself, not a second copy of its fields (01M49W17GGV1K5FZEKJRPV0GNA).

Fields§

§user: Option<String>

The user, for example mike.

§session: Option<String>

The session ID from the session part of a session URI.

§host: Option<String>

The host, for example pangolin.

§repo: Option<String>

The repository as OWNER/REPO, for example como-technologies/riff.

§worktree: Option<String>

The worktree, for example issue-6.

§claim: Option<String>

A claimed work item, for example issue-6.

§lead: Option<bool>

True picks the lead of its user in its repository. Use it with user and repo.

§person: Option<bool>

True picks the terminals of a person: they have no session ID. False picks the agent sessions. Use user=USER,person=true to reach a person and no agent session of that person.

§other: Option<Value>

The JSON of a selector that this build does not know, as it came. Each field above is then empty, and the selector matches no session.

Implementations§

Source§

impl Selector

Source

pub fn serialize<__S>( __self: &Selector, __serializer: __S, ) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Source§

impl<'de> Selector

Source

pub fn deserialize<__D>(__deserializer: __D) -> Result<Selector, __D::Error>
where __D: Deserializer<'de>,

Source§

impl Selector

Source

pub fn is_other(&self) -> bool

True for a selector other: a selector that this build does not know.

Source

pub fn session(id: &str) -> Self

A selector for one session.

Source

pub fn lead(user: &str, repo: &str) -> Self

A selector for the lead of user in the repository repo.

Source

pub fn is_empty(&self) -> bool

True when the selector names no field.

Source

pub fn matches(&self, uri: &SessionUri) -> bool

True when each named field matches the session. A selector other matches no session.

Trait Implementations§

Source§

impl Clone for Selector

Source§

fn clone(&self) -> Selector

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Selector

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Selector

Source§

fn default() -> Selector

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Selector

A build reads each selector that it does not know as a selector other: an object with a field or a value that it does not know, and each other form of JSON (01M3XSF90E9JYYTC13D9THY4WE).

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Selector

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

The FIELD=VALUE pairs. A selector other shows its JSON.

Source§

impl FromStr for Selector

Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses FIELD=VALUE pairs with commas between them.

use riff_core::selector::Selector;

let s: Selector = "user=mike,claim=issue-6".parse()?;
assert_eq!(s.to_string(), "user=mike,claim=issue-6");
let lead: Selector = "user=mike,lead=true".parse()?;
assert_eq!(lead.lead, Some(true));
let person: Selector = "user=mike,person=true".parse()?;
assert_eq!(person.person, Some(true));
assert!("lead=yes".parse::<Selector>().is_err());
assert!("person=yes".parse::<Selector>().is_err());
assert!("".parse::<Selector>().is_err());
assert!("colour=blue".parse::<Selector>().is_err());
Source§

type Err = NameError

The associated error which can be returned from parsing.
Source§

impl JsonSchema for Selector

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for Selector

Source§

fn eq(&self, other: &Selector) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Selector

A selector other writes its JSON as it came.

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Selector

Source§

impl StructuralPartialEq for Selector

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,