Skip to main content

Bluez

Struct Bluez 

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

A connection to BlueZ, with a cached mirror of its object tree.

Implementations§

Source§

impl Bluez

Source

pub fn new(sink: Arc<dyn EventSink>) -> Result<Self>

Connect to the system bus, subscribe to the tree, and load it.

Source

pub fn connection(&self) -> &Arc<Connection> ⓘ

The underlying bus, for the peripheral role’s object exports.

Source

pub fn reload(&self) -> Result<()>

Re-read the whole tree with GetManagedObjects.

Source

pub fn adapters(&self) -> Vec<String>

Every adapter BlueZ is managing, sorted, so hci0 comes first.

Source

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

Use a named adapter for everything from here on.

Takes hci1 or a full object path. Fails if BlueZ is not managing it, rather than silently carrying on with a different one.

Source

pub fn adapter_address(&self) -> Option<String>

The local adapter’s own Bluetooth address, as BlueZ reports it.

Source

pub fn adapter(&self) -> Option<String>

The adapter object path, if one exists.

Source

pub fn is_powered(&self) -> bool

Whether an adapter exists and is powered.

Source

pub fn set_powered(&self, on: bool) -> Result<()>

Turn the adapter on.

Source

pub fn object(&self, path: &str) -> Option<Object>

A snapshot of one object.

Source

pub fn paths_with(&self, interface: &str) -> Vec<String>

Every object path carrying interface.

Source

pub fn children_with(&self, parent: &str, interface: &str) -> Vec<String>

Children of parent carrying interface — how the GATT tree is walked, since BlueZ encodes the hierarchy in the path.

Source

pub fn get_property( &self, path: &str, interface: &str, name: &str, ) -> Result<Value>

Read a property live, bypassing the cache.

Source

pub fn set_property( &self, path: &str, interface: &str, name: &str, value: Value, ) -> Result<()>

Write a property.

Source

pub fn call_async( &self, path: &str, interface: &str, member: &str, args: Vec<Value>, then: impl FnOnce(Result<Message>) + Send + 'static, )

Call a BlueZ method, delivering the reply to a callback.

Callback-based rather than blocking, so the async layer can wrap it without a thread per request — the same shape as the Apple backend.

Source

pub fn call_async_with_fds( &self, path: &str, interface: &str, member: &str, args: Vec<Value>, then: impl FnOnce(Result<(Vec<Value>, Vec<RawFd>)>) + Send + 'static, )

As Bluez::call_async, keeping any descriptors the reply carried.

For AcquireWrite and AcquireNotify, whose answer is a socket. The body holds only an index; the descriptor travelled beside the message.

Source

pub fn call( &self, path: &str, interface: &str, member: &str, args: Vec<Value>, ) -> Result<Message>

Call a BlueZ method and wait.

Source

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

Export an object so BlueZ can call into it — the peripheral role.

Auto Trait Implementations§

§

impl !Freeze for Bluez

§

impl !RefUnwindSafe for Bluez

§

impl !UnwindSafe for Bluez

§

impl Forget for Bluez

§

impl Move for Bluez

§

impl Send for Bluez

§

impl Sync for Bluez

§

impl Unpin for Bluez

§

impl UnsafeUnpin for Bluez

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.