dbus_message_parser/match_rule/
mod.rs

1mod arg;
2mod arg_path;
3mod decode;
4mod encode;
5mod escape;
6mod matching;
7mod split;
8mod unescape;
9
10use crate::{
11    message::MessageType,
12    value::{
13        Bus, BusError, Interface, InterfaceError, Member, MemberError, ObjectPath, ObjectPathError,
14        UniqueConnectionName, UniqueConnectionNameError,
15    },
16};
17pub use arg::{Arg, MAXIMUM_ARG_INDEX};
18pub use arg_path::ArgPath;
19use std::num::ParseIntError;
20use thiserror::Error;
21
22/// This represents an [Match Rule].
23///
24/// [Match Rule]: https://dbus.freedesktop.org/doc/dbus-specification.html#message-bus-routing-match-rules
25#[derive(Debug, PartialEq, Eq)]
26pub enum MatchRule {
27    Type(MessageType),
28    Sender(Bus),
29    Interface(Interface),
30    Member(Member),
31    Path(ObjectPath),
32    PathNamespace(ObjectPath),
33    Destination(UniqueConnectionName),
34    Arg(Arg),
35    ArgPath(ArgPath),
36    Arg0Namespace(Interface),
37    Eavesdrop(bool),
38}
39
40#[derive(Debug, PartialEq, Eq, Error)]
41pub enum MatchRuleError {
42    #[error("Key contains invalid character: {0}")]
43    KeyInvalidChar(char),
44    #[error("Key is emtpy")]
45    KeyEmpty,
46    #[error("Key is unknown")]
47    KeyUnknown,
48    #[error("The equal character is missing")]
49    MissingEqual,
50    #[error("The closing quote is missing")]
51    ValueClosingQuote,
52    #[error("Could not decode sender: {0}")]
53    SenderError(#[from] BusError),
54    #[error("Could not decode type")]
55    TypeUnknown,
56    #[error("Could not decode interface: {0}")]
57    InterfaceError(InterfaceError),
58    #[error("Could not decode member: {0}")]
59    MemberError(#[from] MemberError),
60    #[error("Could not decode path: {0}")]
61    PathError(ObjectPathError),
62    #[error("Could not decode path namespace: {0}")]
63    PathErrorNamespace(ObjectPathError),
64    #[error("Could not decode destination: {0}")]
65    DestinationError(#[from] UniqueConnectionNameError),
66    #[error("The index of the argument is too big: {0} < {MAXIMUM_ARG_INDEX}")]
67    ArgIndexTooBig(usize),
68    #[error("Could not decode arg path: {0}")]
69    ArgPathError(ObjectPathError),
70    #[error("Could not parse index: {0}")]
71    ArgIndexError(#[from] ParseIntError),
72    #[error("Could not decode arg0 namespace: {0}")]
73    Arg0NamespaceError(InterfaceError),
74    #[error("Could not decode eavesdrop")]
75    EavesdropUnknown,
76}