#[derive(Clone, Debug, Default)] /// A "match rule", that can match Messages on its headers. /// /// A field set to "None" means no filter for that header, /// a field set to "Some(_)" must match exactly. pubstruct MatchRule<'a> { /// Match on message type (you typically want to do this) pub msg_type: Option<MessageType>, /// Match on message sender pub sender: Option<BusName<'a>>, /// Match on message object path pub path: Option<Path<'a>>, /// Match on message interface pub interface: Option<Interface<'a>>, /// Match on message member (signal or method name) pub member: Option<Member<'a>>,
_more_fields_may_come: (),
}
fn msg_type_str(m: MessageType) -> &'static str { use MessageType::*; match m {
Signal => "signal",
MethodCall => "method_call",
MethodReturn => "method_return",
Error => "error",
Invalid => unreachable!(),
}
}
impl<'a> MatchRule<'a> { /// Make a string which you can use in the call to "add_match". /// /// Panics: if msg_type is set to Some(MessageType::Invalid) pubfn match_str(&self) -> String { letmut v = vec!(); iflet Some(x) = self.msg_type { v.push(("type", msg_type_str(x))) }; iflet Some(ref x) = self.sender { v.push(("sender", &x)) }; iflet Some(ref x) = self.path { v.push(("path", &x)) }; iflet Some(ref x) = self.interface { v.push(("interface", &x)) }; iflet Some(ref x) = self.member { v.push(("member", &x)) };
// For now we don't need to worry about internal quotes in strings as those are not valid names. // If we start matching against arguments, we need to worry. let v: Vec<_> = v.into_iter().map(|(k, v)| format!("{}='{}'", k, v)).collect();
v.join(",")
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.