pub struct Message { /* private fields */ }
Expand description
A D-Bus Message.
The content of the message are stored in serialized format. To deserialize the body of the
message, use the body
method. You may also access the header and other details with the
various other getters.
Also provided are constructors for messages of different types. These will mainly be useful for
very advanced use cases as typically you will want to create a message for immediate dispatch
and hence use the API provided by Connection
, even when using the low-level API.
Note: The message owns the received FDs and will close them when dropped. You can call
disown_fds
after deserializing to RawFD
using body
if you want to take the ownership.
Implementations
sourceimpl Message
impl Message
sourcepub fn method<B>(
sender: Option<&str>,
destination: Option<&str>,
path: &str,
iface: Option<&str>,
method_name: &str,
body: &B
) -> Result<Self, MessageError> where
B: Serialize + Type,
pub fn method<B>(
sender: Option<&str>,
destination: Option<&str>,
path: &str,
iface: Option<&str>,
method_name: &str,
body: &B
) -> Result<Self, MessageError> where
B: Serialize + Type,
Create a message of type MessageType::MethodCall
.
sourcepub fn signal<B>(
sender: Option<&str>,
destination: Option<&str>,
path: &str,
iface: &str,
signal_name: &str,
body: &B
) -> Result<Self, MessageError> where
B: Serialize + Type,
pub fn signal<B>(
sender: Option<&str>,
destination: Option<&str>,
path: &str,
iface: &str,
signal_name: &str,
body: &B
) -> Result<Self, MessageError> where
B: Serialize + Type,
Create a message of type MessageType::Signal
.
sourcepub fn method_reply<B>(
sender: Option<&str>,
call: &Self,
body: &B
) -> Result<Self, MessageError> where
B: Serialize + Type,
pub fn method_reply<B>(
sender: Option<&str>,
call: &Self,
body: &B
) -> Result<Self, MessageError> where
B: Serialize + Type,
Create a message of type MessageType::MethodReturn
.
sourcepub fn method_error<B>(
sender: Option<&str>,
call: &Self,
name: &str,
body: &B
) -> Result<Self, MessageError> where
B: Serialize + Type,
pub fn method_error<B>(
sender: Option<&str>,
call: &Self,
name: &str,
body: &B
) -> Result<Self, MessageError> where
B: Serialize + Type,
Create a message of type MessageType::MethodError
.
sourcepub fn disown_fds(&mut self)
pub fn disown_fds(&mut self)
Disown the associated file descriptors.
When a message is received over a AF_UNIX socket, it may contain associated FDs. To prevent the message from closing those FDs on drop, you may remove the ownership thanks to this method, after that you are responsible for closing them.
sourcepub fn body_signature<'b, 's: 'b>(
&'s self
) -> Result<Signature<'b>, MessageError>
pub fn body_signature<'b, 's: 'b>(
&'s self
) -> Result<Signature<'b>, MessageError>
The signature of the body.
Note: While zbus treats multiple arguments as a struct (to allow you to use the tuple syntax), D-Bus does not. Since this method gives you the signature expected on the wire by D-Bus, the trailing and leading STRUCT signature parenthesis will not be present in case of multiple arguments.
sourcepub fn primary_header(&self) -> Result<MessagePrimaryHeader, MessageError>
pub fn primary_header(&self) -> Result<MessagePrimaryHeader, MessageError>
Deserialize the primary header.
sourcepub fn header<'h, 'm: 'h>(&'m self) -> Result<MessageHeader<'h>, MessageError>
pub fn header<'h, 'm: 'h>(&'m self) -> Result<MessageHeader<'h>, MessageError>
Deserialize the header.
sourcepub fn fields<'f, 'm: 'f>(&'m self) -> Result<MessageFields<'f>, MessageError>
pub fn fields<'f, 'm: 'f>(&'m self) -> Result<MessageFields<'f>, MessageError>
Deserialize the fields.
sourcepub fn body_unchecked<'d, 'm: 'd, B>(&'m self) -> Result<B, MessageError> where
B: Deserialize<'d> + Type,
pub fn body_unchecked<'d, 'm: 'd, B>(&'m self) -> Result<B, MessageError> where
B: Deserialize<'d> + Type,
Deserialize the body (without checking signature matching).
sourcepub fn body<'d, 'm: 'd, B>(&'m self) -> Result<B, MessageError> where
B: Deserialize<'d> + Type,
pub fn body<'d, 'm: 'd, B>(&'m self) -> Result<B, MessageError> where
B: Deserialize<'d> + Type,
Check the signature and deserialize the body.
Trait Implementations
sourceimpl<S> Sink<Message> for Connection<S> where
S: AsRawFd + Debug + Unpin + Socket,
Async<S>: Socket,
impl<S> Sink<Message> for Connection<S> where
S: AsRawFd + Debug + Unpin + Socket,
Async<S>: Socket,
sourcefn poll_ready(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_ready(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<Result<()>>
Attempts to prepare the Sink
to receive a value. Read more
sourcefn start_send(self: Pin<&mut Self>, msg: Message) -> Result<()>
fn start_send(self: Pin<&mut Self>, msg: Message) -> Result<()>
Begin the process of sending a value to the sink.
Each call to this function must be preceded by a successful call to
poll_ready
which returned Poll::Ready(Ok(()))
. Read more
Auto Trait Implementations
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more