[go: up one dir, main page]

Connection

Struct Connection 

Source
pub struct Connection { /* private fields */ }
Expand description

A connection to D-Bus, async version, which is Send but not Sync.

Implementations§

Source§

impl Connection

Source

pub fn unique_name(&self) -> BusName<'_>

Get the connection’s unique name.

It’s usually something like “:1.54”

Source

pub async fn request_name<'a, N: Into<BusName<'a>>>( &self, name: N, allow_replacement: bool, replace_existing: bool, do_not_queue: bool, ) -> Result<RequestNameReply, Error>

Request a name on the D-Bus.

For detailed information on the flags and return values, see the libdbus documentation.

Source

pub async fn release_name<'a, N: Into<BusName<'a>>>( &self, name: N, ) -> Result<ReleaseNameReply, Error>

Release a previously requested name on the D-Bus.

Source

pub async fn add_match( &self, match_rule: MatchRule<'static>, ) -> Result<MsgMatch, Error>

Adds a new match to the connection, and sets up a callback when this message arrives.

If multiple MatchRules match the same message, then by default only the first will get the callback. This behaviour can be changed for signal messages by calling set_signal_match_mode.

The returned value can be used to remove the match.

Source

pub async fn add_match_no_cb(&self, match_str: &str) -> Result<(), Error>

Adds a new match to the connection, without setting up a callback when this message arrives.

Source

pub async fn remove_match_no_cb(&self, match_str: &str) -> Result<(), Error>

Removes a match from the connection, without removing any callbacks.

Source

pub async fn remove_match(&self, id: Token) -> Result<(), Error>

Removes a previously added match and callback from the connection.

Source

pub fn set_signal_match_mode(&self, match_all: bool)

If true, configures the connection to send signal messages to all matching MatchRule filters added with add_match rather than just the first one. This comes with the following gotchas:

  • The messages might be duplicated, so the message serial might be lost (this is generally not a problem for signals).
  • Panicking inside a match callback might mess with other callbacks, causing them to be permanently dropped.
  • Removing other matches from inside a match callback is not supported.

This is false by default, for a newly-created connection.

Trait Implementations§

Source§

impl AsRef<Channel> for Connection

Source§

fn as_ref(&self) -> &Channel

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl From<Channel> for Connection

Source§

fn from(x: Channel) -> Self

Converts to this type from the input type.
Source§

impl MatchingReceiver for Connection

Source§

type F = Box<dyn FnMut(Message, &Connection) -> bool + Send>

Type of callback
Source§

fn start_receive(&self, m: MatchRule<'static>, f: Self::F) -> Token

Add a callback to be called in case a message matches. Read more
Source§

fn stop_receive(&self, id: Token) -> Option<(MatchRule<'static>, Self::F)>

Remove a previously added callback.
Source§

impl NonblockReply for Connection

Source§

type F = Box<dyn FnOnce(Message, &Connection) + Send>

Callback type
Source§

fn send_with_reply(&self, msg: Message, f: Self::F) -> Result<Token, ()>

Sends a message and calls the callback when a reply is received.
Source§

fn cancel_reply(&self, id: Token) -> Option<Self::F>

Cancels a pending reply.
Source§

fn make_f<G: FnOnce(Message, &Self) + Send + 'static>(g: G) -> Self::F

Internal helper function that creates a callback.
Source§

fn timeout_maker(&self) -> Option<TimeoutMakerCb>

Get the internal timeout maker
Source§

fn set_timeout_maker( &mut self, f: Option<TimeoutMakerCb>, ) -> Option<TimeoutMakerCb>

Set the internal timeout maker
Source§

fn set_waker(&mut self, f: Option<WakerCb>) -> Option<WakerCb>

Set the wakeup call
Source§

impl Process for Connection

Source§

fn process_one(&self, msg: Message)

Dispatches a message.
Source§

fn process_all(&self)

Dispatches all pending messages, without blocking. Read more
Source§

impl Sender for Connection

Source§

fn send(&self, msg: Message) -> Result<u32, ()>

Schedules a message for sending. Read more

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.