pub struct BluetoothEffects<'a, 'b, S: AppState> { /* private fields */ }Expand description
Convenience builder for standard Bluetooth host capabilities.
Implementations§
Source§impl<'a, 'b, S: AppState> BluetoothEffects<'a, 'b, S>
impl<'a, 'b, S: AppState> BluetoothEffects<'a, 'b, S>
Sourcepub fn availability(self) -> EffectBuilder<'a, 'b, S>
pub fn availability(self) -> EffectBuilder<'a, 'b, S>
Queries Bluetooth adapter, permission, and mode availability.
Use this before showing scan, connect, or advertise controls. The result lets the UI distinguish missing hardware, disabled Bluetooth, permission denial, and hosts that support only classic or Low Energy Bluetooth.
Sourcepub fn request_permission(
self,
request: BluetoothPermissionRequest,
) -> EffectBuilder<'a, 'b, S>
pub fn request_permission( self, request: BluetoothPermissionRequest, ) -> EffectBuilder<'a, 'b, S>
Requests Bluetooth or nearby-device permission from the host.
request.reason should explain the product feature that needs nearby
devices. Hosts map the request to the platform permission model, which may
include Bluetooth, location, or nearby-device prompts depending on target.
Sourcepub fn scan_devices(
self,
request: BluetoothScanRequest,
) -> EffectBuilder<'a, 'b, S>
pub fn scan_devices( self, request: BluetoothScanRequest, ) -> EffectBuilder<'a, 'b, S>
Scans for Bluetooth devices matching the request filters.
request.service_uuids narrows discovery to product-relevant services.
timeout_ms should be set for user-driven scans so the host does not keep
nearby-device discovery running indefinitely.
Sourcepub fn connect_device(
self,
request: BluetoothConnectRequest,
) -> EffectBuilder<'a, 'b, S>
pub fn connect_device( self, request: BluetoothConnectRequest, ) -> EffectBuilder<'a, 'b, S>
Connects to a discovered or previously known Bluetooth device.
request.device_id must come from a trusted host result or stored pairing
flow. The success action receives a BluetoothConnection whose
connection_id is used for later read, write, and disconnect requests.
Sourcepub fn disconnect_device(
self,
request: BluetoothDisconnectRequest,
) -> EffectBuilder<'a, 'b, S>
pub fn disconnect_device( self, request: BluetoothDisconnectRequest, ) -> EffectBuilder<'a, 'b, S>
Disconnects a previously opened Bluetooth connection.
request.connection_id should be the id returned by connect_device.
Use this when the user leaves the device workflow or when the app no
longer needs the peripheral.
Sourcepub fn read_characteristic(
self,
request: BluetoothReadRequest,
) -> EffectBuilder<'a, 'b, S>
pub fn read_characteristic( self, request: BluetoothReadRequest, ) -> EffectBuilder<'a, 'b, S>
Reads one Bluetooth characteristic from an active connection.
request names the connection, service UUID, and characteristic UUID.
Hosts should return BluetoothError when the connection is gone or the
characteristic is unavailable.
Sourcepub fn write_characteristic(
self,
request: BluetoothWriteRequest,
) -> EffectBuilder<'a, 'b, S>
pub fn write_characteristic( self, request: BluetoothWriteRequest, ) -> EffectBuilder<'a, 'b, S>
Writes bytes to one Bluetooth characteristic.
request.with_response lets the app choose between acknowledged and
unacknowledged writes where the platform supports both. Reducers should
still handle connection loss and permission errors as normal outcomes.
Sourcepub fn start_advertising(
self,
request: BluetoothAdvertiseRequest,
) -> EffectBuilder<'a, 'b, S>
pub fn start_advertising( self, request: BluetoothAdvertiseRequest, ) -> EffectBuilder<'a, 'b, S>
Starts Bluetooth advertising for hosts that allow apps to advertise.
request supplies the service UUID, optional service data, display name,
and timeout. Mobile and browser platforms often restrict advertising more
heavily than scanning or connecting.
Sourcepub fn stop_advertising(
self,
request: BluetoothStopAdvertiseRequest,
) -> EffectBuilder<'a, 'b, S>
pub fn stop_advertising( self, request: BluetoothStopAdvertiseRequest, ) -> EffectBuilder<'a, 'b, S>
Stops a Bluetooth advertising session.
request.advertisement_id should be the id returned by
start_advertising. Hosts may also stop advertisements automatically when
their timeout expires or the app moves to a background state.
Auto Trait Implementations§
impl<'a, 'b, S> Freeze for BluetoothEffects<'a, 'b, S>
impl<'a, 'b, S> !RefUnwindSafe for BluetoothEffects<'a, 'b, S>
impl<'a, 'b, S> Send for BluetoothEffects<'a, 'b, S>
impl<'a, 'b, S> Sync for BluetoothEffects<'a, 'b, S>
impl<'a, 'b, S> Unpin for BluetoothEffects<'a, 'b, S>
impl<'a, 'b, S> UnsafeUnpin for BluetoothEffects<'a, 'b, S>
impl<'a, 'b, S> !UnwindSafe for BluetoothEffects<'a, 'b, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.