Struct zbus::MessageBuilder

source ·
pub struct MessageBuilder<'a> { /* private fields */ }
Expand description

A builder for Message

Implementations§

source§

impl<'a> MessageBuilder<'a>

source

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.

source

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.

source

pub fn method_return(reply_to: &MessageHeader<'_>) -> Result<Self>

Create a message of type MessageType::MethodReturn.

source

pub fn error<'e: 'a, E>(reply_to: &MessageHeader<'_>, name: E) -> Result<Self>
where E: TryInto<ErrorName<'e>>, E::Error: Into<Error>,

Create a message of type MessageType::Error.

source

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.

source

pub fn sender<'s: 'a, S>(self, sender: S) -> Result<Self>
where S: TryInto<UniqueName<'s>>, S::Error: Into<Error>,

Set the unique name of the sending connection.

source

pub fn path<'p: 'a, P>(self, path: P) -> Result<Self>
where P: TryInto<ObjectPath<'p>>, P::Error: Into<Error>,

Set the object to send a call to, or the object a signal is emitted from.

source

pub fn interface<'i: 'a, I>(self, interface: I) -> Result<Self>
where I: TryInto<InterfaceName<'i>>, I::Error: Into<Error>,

Set the interface to invoke a method call on, or that a signal is emitted from.

source

pub fn member<'m: 'a, M>(self, member: M) -> Result<Self>
where M: TryInto<MemberName<'m>>, M::Error: Into<Error>,

Set the member, either the method name or signal name.

source

pub fn destination<'d: 'a, D>(self, destination: D) -> Result<Self>
where D: TryInto<BusName<'d>>, D::Error: Into<Error>,

Set the name of the connection this message is intended for.

source

pub fn build<B>(self, body: &B) -> Result<Message>

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.

source

pub unsafe fn build_raw_body<'b, S>( self, body_bytes: &[u8], signature: S, fds: Vec<RawFd>, ) -> Result<Message>
where S: TryInto<Signature<'b>>, S::Error: Into<Error>,

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>

source§

fn clone(&self) -> MessageBuilder<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for MessageBuilder<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'m> From<MessageHeader<'m>> for MessageBuilder<'m>

source§

fn from(header: MessageHeader<'m>) -> Self

Converts to this type from the input type.

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more