pub struct Builder<'a> { /* private fields */ }
Expand description
A builder for Message
Implementations§
Source§impl<'a> Builder<'a>
impl<'a> Builder<'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>,
👎Deprecated since 4.0.0: Please use Message::method
instead
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>,
Message::method
insteadCreate a message of type Type::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>,
👎Deprecated since 4.0.0: Please use Message::signal
instead
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>,
Message::signal
insteadCreate a message of type Type::Signal
.
Sourcepub fn method_return(reply_to: &Header<'_>) -> Result<Self>
👎Deprecated since 4.0.0: Please use Message::method_reply
instead
pub fn method_return(reply_to: &Header<'_>) -> Result<Self>
Message::method_reply
insteadCreate a message of type Type::MethodReturn
.
Sourcepub fn error<'e: 'a, E>(reply_to: &Header<'_>, name: E) -> Result<Self>
👎Deprecated since 4.0.0: Please use Message::method_error
instead
pub fn error<'e: 'a, E>(reply_to: &Header<'_>, name: E) -> Result<Self>
Message::method_error
insteadCreate a message of type Type::Error
.
Sourcepub fn with_flags(self, flag: Flags) -> Result<Self>
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.
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 endian(self, endian: Endian) -> Self
pub fn endian(self, endian: Endian) -> Self
Set the endianness of the message.
The default endianness is native.
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<OwnedFd>,
) -> Result<Message>
pub unsafe fn build_raw_body<'b, S>( self, body_bytes: &[u8], signature: S, fds: Vec<OwnedFd>, ) -> 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.