Struct foxbox_taxonomy::selector::SetterSelector [] [src]

pub struct SetterSelector {
    pub id: Exactly<Id<Setter>>,
    pub parent: Exactly<Id<ServiceId>>,
    pub tags: HashSet<Id<TagId>>,
    pub service_tags: HashSet<Id<TagId>>,
    pub kind: Exactly<ChannelKind>,
    // some fields omitted
}

A selector for one or more setter channels.

JSON

A selector is an object with the following fields:

While each field is optional, at least one field must be provided.

use foxbox_taxonomy::selector::*;

// A selector with all fields defined.
let json_selector = "{                         \
  \"id\": \"setter 1\",                        \
  \"service\": \"service 1\",                  \
  \"tags\": [\"tag 1\", \"tag 2\"],            \
  \"service_tags\": [\"tag 3\", \"tag 4\"],    \
  \"kind\": \"Ready\"                          \
}";

SetterSelector::from_str(json_selector).unwrap();

// The following will be rejected because no field is provided:
let json_empty = "{}";
match SetterSelector::from_str(json_empty) {
  Err(ParseError::EmptyObject {..}) => { /* as expected */ },
  other => panic!("Unexpected result {:?}", other)
}

Fields

id

If Exactly(id), return only the channel with the corresponding id.

parent

If Exactly(id), return only channels that are immediate children of service id.

tags

Restrict results to channels that have all the tags in tags.

service_tags

Restrict results to channels offered by a service that has all the tags in tags.

kind

If Exactly(k), restrict results to channels that accept values of kind k.

Methods

impl SetterSelector

fn new() -> Self

Create a new selector that accepts all getter channels.

fn with_id(self, id: Id<Setter>) -> Self

Selector to a channel with a specific id.

fn with_parent(self, id: Id<ServiceId>) -> Self

Selector to channels with a specific parent.

fn with_kind(self, kind: ChannelKind) -> Self

Selector to channels with a specific kind.

fn with_tags(self, tags: Vec<Id<TagId>>) -> Self

Restrict to channels that have all the tags in tags.

fn with_service_tags(self, tags: Vec<Id<TagId>>) -> Self

Restrict to channels offered by a service that has all the tags in tags.

fn and(self, other: Self) -> Self

Restrict results to channels that are accepted by two selector.

fn matches(&self, service_tags: &HashSet<Id<TagId>>, channel: &Channel<Setter>) -> bool

Determine if a channel is matched by this selector.

Trait Implementations

impl Deserialize for SetterSelector

fn deserialize<__D>(deserializer: &mut __D) -> Result<SetterSelector, __D::Error> where __D: Deserializer

impl Parser<SetterSelector> for SetterSelector

fn description() -> String

fn parse(path: Path, source: &mut JSON) -> Result<Self, ParseError>

fn from_str(source: &str) -> Result<T, ParseError>

fn take(path: Path, source: &mut JSON, field_name: &str) -> Result<T, ParseError>

fn take_opt(path: Path, source: &mut JSON, field_name: &str) -> Option<Result<T, ParseError>>

fn take_vec_opt(path: Path, source: &mut JSON, field_name: &str) -> Option<Result<Vec<T>, ParseError>>

fn take_vec(path: Path, source: &mut JSON, field_name: &str) -> Result<Vec<T>, ParseError>

Derived Implementations

impl Default for SetterSelector

fn default() -> SetterSelector

impl Debug for SetterSelector

fn fmt(&self, __arg_0: &mut Formatter) -> Result

impl Clone for SetterSelector

fn clone(&self) -> SetterSelector

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