Struct zbus::blocking::Connection
source · [−]pub struct Connection { /* private fields */ }
Expand description
A blocking wrapper of zbus::Connection
.
Most of the API is very similar to zbus::Connection
, except it’s blocking. One
notable difference is that there is no equivalent of Sink
implementation provided.
Implementations
Max number of messages to queue.
Set the max number of messages to queue.
The server’s GUID.
The unique name as assigned by the message bus or None
if not a message bus connection.
Send msg
to the peer.
The connection sets a unique serial number on the message before sending it off.
On successfully sending off msg
, the assigned serial number is returned.
pub fn call_method<'d, 'p, 'i, 'm, D, P, I, M, B>(
&self,
destination: Option<D>,
path: P,
iface: Option<I>,
method_name: M,
body: &B
) -> Result<Arc<Message>> where
D: TryInto<BusName<'d>>,
P: TryInto<ObjectPath<'p>>,
I: TryInto<InterfaceName<'i>>,
M: TryInto<MemberName<'m>>,
D::Error: Into<Error>,
P::Error: Into<Error>,
I::Error: Into<Error>,
M::Error: Into<Error>,
B: Serialize + DynamicType,
pub fn call_method<'d, 'p, 'i, 'm, D, P, I, M, B>(
&self,
destination: Option<D>,
path: P,
iface: Option<I>,
method_name: M,
body: &B
) -> Result<Arc<Message>> where
D: TryInto<BusName<'d>>,
P: TryInto<ObjectPath<'p>>,
I: TryInto<InterfaceName<'i>>,
M: TryInto<MemberName<'m>>,
D::Error: Into<Error>,
P::Error: Into<Error>,
I::Error: Into<Error>,
M::Error: Into<Error>,
B: Serialize + DynamicType,
Send a method call.
Create a method-call message, send it over the connection, then wait for the reply. Incoming
messages are received through receive_message
until the matching method reply (error or
return) is received.
On successful reply, an Ok(Message)
is returned. On error, an Err
is returned. D-Bus
error replies are returned as MethodError
.
pub fn emit_signal<'d, 'p, 'i, 'm, D, P, I, M, B>(
&self,
destination: Option<D>,
path: P,
iface: I,
signal_name: M,
body: &B
) -> Result<()> where
D: TryInto<BusName<'d>>,
P: TryInto<ObjectPath<'p>>,
I: TryInto<InterfaceName<'i>>,
M: TryInto<MemberName<'m>>,
D::Error: Into<Error>,
P::Error: Into<Error>,
I::Error: Into<Error>,
M::Error: Into<Error>,
B: Serialize + DynamicType,
pub fn emit_signal<'d, 'p, 'i, 'm, D, P, I, M, B>(
&self,
destination: Option<D>,
path: P,
iface: I,
signal_name: M,
body: &B
) -> Result<()> where
D: TryInto<BusName<'d>>,
P: TryInto<ObjectPath<'p>>,
I: TryInto<InterfaceName<'i>>,
M: TryInto<MemberName<'m>>,
D::Error: Into<Error>,
P::Error: Into<Error>,
I::Error: Into<Error>,
M::Error: Into<Error>,
B: Serialize + DynamicType,
Emit a signal.
Create a signal message, and send it over the connection.
Reply to a message.
Given an existing message (likely a method call), send a reply back to the caller with the
given body
.
Returns the message serial number.
Reply an error to a message.
Given an existing message (likely a method call), send an error reply back to the caller
with the given error_name
and body
.
Returns the message serial number.
Reply to a method call with an error.
Given an existing method call message header, send an error reply back to the caller using one of the standard interface reply types.
Returns the message serial number.
pub fn request_name<'w, W>(&self, well_known_name: W) -> Result<()> where
W: TryInto<WellKnownName<'w>>,
W::Error: Into<Error>,
pub fn request_name<'w, W>(&self, well_known_name: W) -> Result<()> where
W: TryInto<WellKnownName<'w>>,
W::Error: Into<Error>,
Register a well-known name for this service on the bus.
You can request multiple names for the same ObjectServer
. Use Connection::release_name
for deregistering names registered through this method.
Note that exclusive ownership without queueing is requested (using
crate::fdo::RequestNameFlags::ReplaceExisting
and
crate::fdo::RequestNameFlags::DoNotQueue
flags) since that is the most typical case. If
that is not what you want, you should use crate::fdo::DBusProxy::request_name
instead
(but make sure then that name is requested after you’ve setup your service
implementation with the ObjectServer
).
pub fn release_name<'w, W>(&self, well_known_name: W) -> Result<bool> where
W: TryInto<WellKnownName<'w>>,
W::Error: Into<Error>,
pub fn release_name<'w, W>(&self, well_known_name: W) -> Result<bool> where
W: TryInto<WellKnownName<'w>>,
W::Error: Into<Error>,
Deregister a previously registered well-known name for this service on the bus.
Use this method to deregister a well-known name, registered through
Connection::request_name
.
Unless an error is encountered, returns Ok(true)
if name was previously registered with
the bus through self
and it has now been successfully deregistered, Ok(false)
if name
was not previously registered or already deregistered.
Checks if self
is a connection to a message bus.
This will return false
for p2p connections.
Get a reference to the associated ObjectServer
.
The ObjectServer
is created on-demand.
Get a reference to the underlying async Connection.
Get the underlying async Connection, consuming self
.
Returns a listener, notified on various connection activity.
This function is meant for the caller to implement idle or timeout on inactivity.
Trait Implementations
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Auto Trait Implementations
impl !RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl !UnwindSafe for Connection
Blanket Implementations
Mutably borrows from an owned value. Read more