zbus::message

Struct Builder

Source
pub struct Builder<'a> { /* private fields */ }
Expand description

A builder for Message

Implementations§

Source§

impl<'a> Builder<'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>,

👎Deprecated since 4.0.0: Please use Message::method instead

Create a message of type Type::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>,

👎Deprecated since 4.0.0: Please use Message::signal instead

Create a message of type Type::Signal.

Source

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

👎Deprecated since 4.0.0: Please use Message::method_reply instead

Create a message of type Type::MethodReturn.

Source

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

👎Deprecated since 4.0.0: Please use Message::method_error instead

Create a message of type Type::Error.

Source

pub fn with_flags(self, flag: Flags) -> Result<Self>

Add flags to the message.

See Flags 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 endian(self, endian: Endian) -> Self

Set the endianness of the message.

The default endianness is native.

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<OwnedFd>, ) -> 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 Builder<'a>

Source§

fn clone(&self) -> Builder<'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 Builder<'a>

Source§

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

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

impl<'m> From<Header<'m>> for Builder<'m>

Source§

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

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> Freeze for Builder<'a>

§

impl<'a> RefUnwindSafe for Builder<'a>

§

impl<'a> Send for Builder<'a>

§

impl<'a> Sync for Builder<'a>

§

impl<'a> Unpin for Builder<'a>

§

impl<'a> UnwindSafe for Builder<'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 u8)

🔬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