zbus::blocking

Struct 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

source

pub fn session() -> Result<Self>

Create a Connection to the session/user message bus.

source

pub fn system() -> Result<Self>

Create a Connection to the system-wide message bus.

source

pub fn max_queued(&self) -> usize

The capacity of the main (unfiltered) queue.

source

pub fn set_max_queued(self, max: usize)

Set the capacity of the main (unfiltered) queue.

source

pub fn server_guid(&self) -> &str

The server’s GUID.

source

pub fn unique_name(&self) -> Option<&OwnedUniqueName>

The unique name as assigned by the message bus or None if not a message bus connection.

source

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.

source

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.

source

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.

source

pub fn reply<B>(&self, call: &Message, body: &B) -> Result<u32>

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.

source

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.

source

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.

source

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.

Blocking version of crate::Connection::request_name. See docs there for more details and caveats.

source

pub fn request_name_with_flags<'w, W>( &self, well_known_name: W, flags: BitFlags<RequestNameFlags>, ) -> Result<RequestNameReply>
where W: TryInto<WellKnownName<'w>>, W::Error: Into<Error>,

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.

source

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.

source

pub fn is_bus(&self) -> bool

Checks if self is a connection to a message bus.

This will return false for p2p connections.

source

pub fn object_server(&self) -> impl Deref<Target = ObjectServer> + '_

Get a reference to the associated ObjectServer.

The ObjectServer is created on-demand.

source

pub fn inner(&self) -> &Connection

Get a reference to the underlying async Connection.

source

pub fn into_inner(self) -> Connection

Get the underlying async Connection, consuming self.

source

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.

source

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

source§

fn clone(&self) -> Connection

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 Debug for Connection

source§

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

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

impl From<&Connection> for MessageIterator

source§

fn from(conn: &Connection) -> Self

Converts to this type from the input type.
source§

impl From<&MessageIterator> for Connection

source§

fn from(iter: &MessageIterator) -> Connection

Converts to this type from the input type.
source§

impl From<Connection> for Connection

source§

fn from(conn: Connection) -> Self

Converts to this type from the input type.
source§

impl From<Connection> for Connection

source§

fn from(conn: Connection) -> Self

Converts to this type from the input type.
source§

impl From<Connection> for MessageIterator

source§

fn from(conn: Connection) -> Self

Converts to this type from the input type.
source§

impl From<MessageIterator> for Connection

source§

fn from(iter: MessageIterator) -> Connection

Converts to this type from the input type.

Auto Trait Implementations§

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