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§
source§impl Connection
impl Connection
sourcepub fn max_queued(&self) -> usize
pub fn max_queued(&self) -> usize
The capacity of the main (unfiltered) queue.
sourcepub fn set_max_queued(self, max: usize)
pub fn set_max_queued(self, max: usize)
Set the capacity of the main (unfiltered) queue.
sourcepub fn server_guid(&self) -> &str
pub fn server_guid(&self) -> &str
The server’s GUID.
sourcepub fn unique_name(&self) -> Option<&OwnedUniqueName>
pub fn unique_name(&self) -> Option<&OwnedUniqueName>
The unique name as assigned by the message bus or None
if not a message bus connection.
sourcepub fn send_message(&self, msg: Message) -> Result<u32>
pub fn send_message(&self, msg: Message) -> Result<u32>
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.
sourcepub 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>>
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>>
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
.
sourcepub 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<()>
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<()>
Emit a signal.
Create a signal message, and send it over the connection.
sourcepub fn reply<B>(&self, call: &Message, body: &B) -> Result<u32>where
B: Serialize + DynamicType,
pub fn reply<B>(&self, call: &Message, body: &B) -> Result<u32>where
B: Serialize + DynamicType,
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.
sourcepub fn reply_error<'e, E, B>(
&self,
call: &Message,
error_name: E,
body: &B,
) -> Result<u32>
pub fn reply_error<'e, E, B>( &self, call: &Message, error_name: E, body: &B, ) -> Result<u32>
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.
sourcepub fn reply_dbus_error(
&self,
call: &MessageHeader<'_>,
err: impl DBusError,
) -> Result<u32>
pub fn reply_dbus_error( &self, call: &MessageHeader<'_>, err: impl DBusError, ) -> Result<u32>
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.
sourcepub fn request_name<'w, W>(&self, well_known_name: W) -> Result<()>
pub fn request_name<'w, W>(&self, well_known_name: W) -> Result<()>
Register a well-known name for this service on the bus.
Blocking version of crate::Connection::request_name
. See docs there for more details
and caveats.
sourcepub fn request_name_with_flags<'w, W>(
&self,
well_known_name: W,
flags: BitFlags<RequestNameFlags>,
) -> Result<RequestNameReply>
pub fn request_name_with_flags<'w, W>( &self, well_known_name: W, flags: BitFlags<RequestNameFlags>, ) -> Result<RequestNameReply>
Register a well-known name for this service on the bus.
Blocking version of crate::Connection::request_name_with_flags
. See docs there for more
details and caveats.
sourcepub fn release_name<'w, W>(&self, well_known_name: W) -> Result<bool>
pub fn release_name<'w, W>(&self, well_known_name: W) -> Result<bool>
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.
sourcepub fn is_bus(&self) -> bool
pub fn is_bus(&self) -> bool
Checks if self
is a connection to a message bus.
This will return false
for p2p connections.
sourcepub fn object_server(&self) -> impl Deref<Target = ObjectServer> + '_
pub fn object_server(&self) -> impl Deref<Target = ObjectServer> + '_
Get a reference to the associated ObjectServer
.
The ObjectServer
is created on-demand.
sourcepub fn inner(&self) -> &Connection
pub fn inner(&self) -> &Connection
Get a reference to the underlying async Connection.
sourcepub fn into_inner(self) -> Connection
pub fn into_inner(self) -> Connection
Get the underlying async Connection, consuming self
.
sourcepub fn monitor_activity(&self) -> EventListener
pub fn monitor_activity(&self) -> EventListener
Returns a listener, notified on various connection activity.
This function is meant for the caller to implement idle or timeout on inactivity.
sourcepub fn peer_credentials(&self) -> Result<ConnectionCredentials>
pub fn peer_credentials(&self) -> Result<ConnectionCredentials>
Returns the peer credentials.
The fields are populated on the best effort basis. Some or all fields may not even make
sense for certain sockets or on certain platforms and hence will be set to None
.
§Caveats
Currently unix_group_ids
and linux_security_label
fields are not populated.
Trait Implementations§
source§impl Clone for Connection
impl Clone for Connection
source§fn clone(&self) -> Connection
fn clone(&self) -> Connection
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Connection
impl Debug for Connection
source§impl From<&Connection> for MessageIterator
impl From<&Connection> for MessageIterator
source§fn from(conn: &Connection) -> Self
fn from(conn: &Connection) -> Self
source§impl From<&MessageIterator> for Connection
impl From<&MessageIterator> for Connection
source§fn from(iter: &MessageIterator) -> Connection
fn from(iter: &MessageIterator) -> Connection
source§impl From<Connection> for Connection
impl From<Connection> for Connection
source§fn from(conn: Connection) -> Self
fn from(conn: Connection) -> Self
source§impl From<Connection> for Connection
impl From<Connection> for Connection
source§fn from(conn: Connection) -> Self
fn from(conn: Connection) -> Self
source§impl From<Connection> for MessageIterator
impl From<Connection> for MessageIterator
source§fn from(conn: Connection) -> Self
fn from(conn: Connection) -> Self
source§impl From<MessageIterator> for Connection
impl From<MessageIterator> for Connection
source§fn from(iter: MessageIterator) -> Connection
fn from(iter: MessageIterator) -> Connection
Auto Trait Implementations§
impl Freeze for Connection
impl !RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl !UnwindSafe for Connection
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
)