Struct zbus::MessageBuilder
source · pub struct MessageBuilder<'a> { /* private fields */ }
Expand description
A builder for Message
Implementations§
source§impl<'a> MessageBuilder<'a>
impl<'a> MessageBuilder<'a>
sourcepub fn method_call<'p: 'a, 'm: 'a, P, M>(
path: P,
method_name: M,
) -> Result<Self>where
P: TryInto<ObjectPath<'p>>,
M: TryInto<MemberName<'m>>,
P::Error: Into<Error>,
M::Error: Into<Error>,
pub fn method_call<'p: 'a, 'm: 'a, P, M>(
path: P,
method_name: M,
) -> Result<Self>where
P: TryInto<ObjectPath<'p>>,
M: TryInto<MemberName<'m>>,
P::Error: Into<Error>,
M::Error: Into<Error>,
Create a message of type MessageType::MethodCall
.
sourcepub fn signal<'p: 'a, 'i: 'a, 'm: 'a, P, I, M>(
path: P,
interface: I,
name: M,
) -> Result<Self>where
P: TryInto<ObjectPath<'p>>,
I: TryInto<InterfaceName<'i>>,
M: TryInto<MemberName<'m>>,
P::Error: Into<Error>,
I::Error: Into<Error>,
M::Error: Into<Error>,
pub fn signal<'p: 'a, 'i: 'a, 'm: 'a, P, I, M>(
path: P,
interface: I,
name: M,
) -> Result<Self>where
P: TryInto<ObjectPath<'p>>,
I: TryInto<InterfaceName<'i>>,
M: TryInto<MemberName<'m>>,
P::Error: Into<Error>,
I::Error: Into<Error>,
M::Error: Into<Error>,
Create a message of type MessageType::Signal
.
sourcepub fn method_return(reply_to: &MessageHeader<'_>) -> Result<Self>
pub fn method_return(reply_to: &MessageHeader<'_>) -> Result<Self>
Create a message of type MessageType::MethodReturn
.
sourcepub fn error<'e: 'a, E>(reply_to: &MessageHeader<'_>, name: E) -> Result<Self>
pub fn error<'e: 'a, E>(reply_to: &MessageHeader<'_>, name: E) -> Result<Self>
Create a message of type MessageType::Error
.
sourcepub fn with_flags(self, flag: MessageFlags) -> Result<Self>
pub fn with_flags(self, flag: MessageFlags) -> Result<Self>
Add flags to the message.
See MessageFlags
documentation for the meaning of the flags.
The function will return an error if invalid flags are given for the message type.
sourcepub fn sender<'s: 'a, S>(self, sender: S) -> Result<Self>
pub fn sender<'s: 'a, S>(self, sender: S) -> Result<Self>
Set the unique name of the sending connection.
sourcepub fn path<'p: 'a, P>(self, path: P) -> Result<Self>
pub fn path<'p: 'a, P>(self, path: P) -> Result<Self>
Set the object to send a call to, or the object a signal is emitted from.
sourcepub fn interface<'i: 'a, I>(self, interface: I) -> Result<Self>
pub fn interface<'i: 'a, I>(self, interface: I) -> Result<Self>
Set the interface to invoke a method call on, or that a signal is emitted from.
sourcepub fn member<'m: 'a, M>(self, member: M) -> Result<Self>
pub fn member<'m: 'a, M>(self, member: M) -> Result<Self>
Set the member, either the method name or signal name.
sourcepub fn destination<'d: 'a, D>(self, destination: D) -> Result<Self>
pub fn destination<'d: 'a, D>(self, destination: D) -> Result<Self>
Set the name of the connection this message is intended for.
sourcepub fn build<B>(self, body: &B) -> Result<Message>where
B: Serialize + DynamicType,
pub fn build<B>(self, body: &B) -> Result<Message>where
B: Serialize + DynamicType,
Build the Message
with the given body.
You may pass ()
as the body if the message has no body.
The caller is currently required to ensure that the resulting message contains the headers as compliant with the specification. Additional checks may be added to this builder over time as needed.
sourcepub unsafe fn build_raw_body<'b, S>(
self,
body_bytes: &[u8],
signature: S,
fds: Vec<RawFd>,
) -> Result<Message>
pub unsafe fn build_raw_body<'b, S>( self, body_bytes: &[u8], signature: S, fds: Vec<RawFd>, ) -> Result<Message>
Create a new message from a raw slice of bytes to populate the body with, rather than by serializing a value. The message body will be the exact bytes.
§Safety
This method is unsafe because it can be used to build an invalid message.
Trait Implementations§
source§impl<'a> Clone for MessageBuilder<'a>
impl<'a> Clone for MessageBuilder<'a>
source§fn clone(&self) -> MessageBuilder<'a>
fn clone(&self) -> MessageBuilder<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'a> Debug for MessageBuilder<'a>
impl<'a> Debug for MessageBuilder<'a>
source§impl<'m> From<MessageHeader<'m>> for MessageBuilder<'m>
impl<'m> From<MessageHeader<'m>> for MessageBuilder<'m>
source§fn from(header: MessageHeader<'m>) -> Self
fn from(header: MessageHeader<'m>) -> Self
Auto Trait Implementations§
impl<'a> !Freeze for MessageBuilder<'a>
impl<'a> RefUnwindSafe for MessageBuilder<'a>
impl<'a> Send for MessageBuilder<'a>
impl<'a> Sync for MessageBuilder<'a>
impl<'a> Unpin for MessageBuilder<'a>
impl<'a> UnwindSafe for MessageBuilder<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)