pub struct Connection { /* private fields */ }Expand description
A connection to a message bus.
Implementations§
Source§impl Connection
impl Connection
Sourcepub fn system() -> Result<Self>
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.
Sourcepub fn connect(address: &str) -> Result<Self>
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.
Sourcepub fn unique_name(&self) -> String
pub fn unique_name(&self) -> String
This connection’s unique bus name, e.g. :1.42.
Sourcepub fn call_async(
&self,
message: Message,
on_reply: Box<dyn FnOnce(Result<Message>) + Send>,
)
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.
Sourcepub fn call_blocking_with_fds(
&self,
message: Message,
timeout: Duration,
) -> Result<(Message, Vec<RawFd>)>
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.
Sourcepub fn call_blocking(
&self,
message: Message,
timeout: Duration,
) -> Result<Message>
pub fn call_blocking( &self, message: Message, timeout: Duration, ) -> Result<Message>
Send a method call and wait for the reply.
Sourcepub fn send(&self, message: Message) -> Result<()>
pub fn send(&self, message: Message) -> Result<()>
Send a signal or a reply, expecting nothing back.
Sourcepub fn add_match(&self, rule: &str, handler: SignalHandler) -> Result<()>
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.
Sourcepub fn export(&self, path: &str, handler: Arc<dyn ObjectHandler>)
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.
Sourcepub fn request_name(&self, name: &str) -> Result<()>
pub fn request_name(&self, name: &str) -> Result<()>
Claim a well-known bus name.
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Whether the reader thread is still running.