Skip to main content

Connection

Struct Connection 

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

A connection to a message bus.

Implementations§

Source§

impl Connection

Source

pub fn system() -> Result<Self>

Connect to the system bus, where BlueZ lives.

WEBBLUETOOTH_DBUS_ADDRESS overrides the address, which is how the test harness points at a private bus carrying a mocked org.bluez instead of the real one.

Source

pub fn session() -> Result<Self>

Connect to the session bus.

Source

pub fn connect(address: &str) -> Result<Self>

Connect to a bus at a D-Bus address.

Only unix:path= and unix:abstract= transports are supported; TCP is not, because BlueZ is never on one.

Source

pub fn unique_name(&self) -> String

This connection’s unique bus name, e.g. :1.42.

Source

pub fn call_async( &self, message: Message, on_reply: Box<dyn FnOnce(Result<Message>) + Send>, )

Send a method call; on_reply runs on the reader thread when the answer arrives. This is the primitive the async layer wraps.

Source

pub fn call_blocking_with_fds( &self, message: Message, timeout: Duration, ) -> Result<(Message, Vec<RawFd>)>

Send a method call and wait for the reply, claiming any descriptors.

For methods like AcquireWrite whose answer is a file descriptor: the body carries only an index, and the descriptor itself arrived beside the message. The caller owns what comes back and must close it.

Source

pub fn call_blocking( &self, message: Message, timeout: Duration, ) -> Result<Message>

Send a method call and wait for the reply.

Source

pub fn send(&self, message: Message) -> Result<()>

Send a signal or a reply, expecting nothing back.

Source

pub fn add_match(&self, rule: &str, handler: SignalHandler) -> Result<()>

Subscribe to signals. The rule is a D-Bus match expression, e.g. type='signal',interface='org.freedesktop.DBus.Properties'.

The handler sees every signal, because the bus may deliver more than the rule asks for; filter inside it.

Source

pub fn export(&self, path: &str, handler: Arc<dyn ObjectHandler>)

Export an object. path matches itself and everything beneath it, which is how one handler can serve a whole GATT application tree.

Source

pub fn request_name(&self, name: &str) -> Result<()>

Claim a well-known bus name.

Source

pub fn is_connected(&self) -> bool

Whether the reader thread is still running.

Source§

impl Connection

Source

pub fn take_fds(&self, serial: u32) -> Vec<RawFd>

Take the descriptors that came back with the reply to serial.

Empty unless the method actually returned one. The caller owns them and must close them; nothing else will.

Trait Implementations§

Source§

impl Drop for Connection

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.