pub struct MatchRule {
    pub sender: Option<Arc<str>>,
    pub path: Option<Arc<str>>,
    pub path_namespace: Option<Arc<str>>,
    pub interface: Option<Arc<str>>,
    pub member: Option<Arc<str>>,
    /* private fields */
}
Expand description

Represents a match for incoming signals.

Signals match a MatchRule if they match every field. When one of the fields is None it is equivelent to a wildcard for that field, causing that field to be matching for every signal.

MatchRule’s are ordered by their specificity. If one MatchRule is ‘less than’ another, then it is more specific than the other one. See the Ord impl for details.

Fields§

§sender: Option<Arc<str>>

Checks against the sender of the signal.

§path: Option<Arc<str>>

Matches against the object path of the signal requiring an exact match (no children). path and path_namespace cannot be used simultanously.

§path_namespace: Option<Arc<str>>

Matches against the object path of the signal. It accepts an exact match, or a child of path_namespace. path and path_namespace cannot be used simultanously.

§interface: Option<Arc<str>>

Matches against the interface of the signal.

§member: Option<Arc<str>>

Matches against the signal member.

Implementations§

source§

impl MatchRule

source

pub fn new() -> Self

source

pub fn sender<S: Into<String>>(&mut self, sender: S) -> &mut Self

source

pub fn path<S: Into<String>>(&mut self, path: S) -> &mut Self

source

pub fn path_namespace<S: Into<String>>( &mut self, path_namespace: S ) -> &mut Self

source

pub fn interface<S: Into<String>>(&mut self, interface: S) -> &mut Self

source

pub fn member<S: Into<String>>(&mut self, member: S) -> &mut Self

source

pub fn is_empty(&self) -> bool

source

pub fn matches(&self, msg: &MarshalledMessage) -> bool

Returns true if the message is a signal and matches the rule.

source

pub fn match_string(&self) -> String

Returns the org.freedesktop.DBus.AddMatch match rule string.

Trait Implementations§

source§

impl Clone for MatchRule

source§

fn clone(&self) -> Self

Returns a copy 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 MatchRule

source§

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

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

impl Default for MatchRule

source§

fn default() -> MatchRule

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

impl Ord for MatchRule

MatchRules are ordered by their specificity. If one match rule is ‘less than’ another then it is more specific than the other. When evaluating specificity the following steps are taken:

  1. If one rule has Some sender and the other None then, the former is less than the latter. Otherwise continue to the next step.
  2. If one rule has Some path and the other None then, the former is less than the latter. Otherwise continue to the next step.
  3. If one rule has Some path_namespace and the other None then, the former is less than the latter. Otherwise continue to the next step.
  4. If both rules have Some path_namespace and one is a subset of the other than the former is less than the latter. Otherwise continue to the next step.
  5. If one rule has Some interface and the other None then, the former is less than the latter. Otherwise continue to the next step.
  6. If one rule has Some member and the other None then, the former is less than the latter. Otherwise continue to the next step.
  7. Compare sender field. If not equal return the Ordering, otherwise continue to the next step.
  8. Compare path field. If not equal return the Ordering, otherwise continue to the next step.
  9. Compare path_namespace field. If not equal return the Ordering, otherwise continue to the next step.
  10. Compare interface field. If not equal return the Ordering, otherwise continue to the next step.
  11. Compare member field, and return the result.
source§

fn cmp(&self, other: &Self) -> COrdering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<MatchRule> for MatchRule

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<MatchRule> for MatchRule

source§

fn partial_cmp(&self, other: &MatchRule) -> Option<COrdering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Eq for MatchRule

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> ToOwned for Twhere T: Clone,

§

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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.