pub trait MessageConversion: BusProperties {
type Body: Type + Serialize + for<'a> Deserialize<'a>;
// Required methods
fn from_message_unchecked(msg: &Message) -> Result<Self, AtspiError>
where Self: Sized;
fn from_message_unchecked_parts(
obj_ref: ObjectRef,
body: Self::Body,
) -> Result<Self, AtspiError>
where Self: Sized;
fn body(&self) -> Self::Body;
}
Required Associated Types§
Sourcetype Body: Type + Serialize + for<'a> Deserialize<'a>
type Body: Type + Serialize + for<'a> Deserialize<'a>
What is the body type of this event.
Required Methods§
Sourcefn from_message_unchecked(msg: &Message) -> Result<Self, AtspiError>where
Self: Sized,
fn from_message_unchecked(msg: &Message) -> Result<Self, AtspiError>where
Self: Sized,
Build an event from a zbus::Message
reference.
This function will not check for any of the following error conditions:
- That the message has an interface:
AtspiError::MissingInterface
- That the message interface matches the one for the event:
AtspiError::InterfaceMatch
- That the message has an member:
AtspiError::MissingMember
- That the message member matches the one for the event:
AtspiError::MemberMatch
- That the message signature matches the one for the event:
AtspiError::SignatureMatch
Therefore, this should only be used when one has checked the above conditions.
These must be checked manually.
Alternatively, there is the MessageConversionExt::try_from_message
that will check these
conditions for you.
This type also implements TryFrom<&zbus::Message>
; consider using this if you are not an
internal developer.
§Errors
It is possible to get a AtspiError::Zvariant
error if you do not check the proper
conditions before calling this.
Sourcefn from_message_unchecked_parts(
obj_ref: ObjectRef,
body: Self::Body,
) -> Result<Self, AtspiError>where
Self: Sized,
fn from_message_unchecked_parts(
obj_ref: ObjectRef,
body: Self::Body,
) -> Result<Self, AtspiError>where
Self: Sized,
Build an event from an ObjectRef
and Self::Body
.
This function will not check for any of the following error conditions:
- That the message has an interface:
AtspiError::MissingInterface
- That the message interface matches the one for the event:
AtspiError::InterfaceMatch
- That the message has an member:
AtspiError::MissingMember
- That the message member matches the one for the event:
AtspiError::MemberMatch
Therefore, this should only be used when one has checked the above conditions.
§Errors
Some Self::Body
types may fallibly convert data fields contained in the body.
If this happens, then the function will return an error.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.