pub struct Controller { /* private fields */ }Expand description
A connected controller.
Implementations§
Source§impl Controller
impl Controller
Sourcepub async fn connect(timeout: Duration) -> Result<Controller, Error>
pub async fn connect(timeout: Duration) -> Result<Controller, Error>
Finds a controller and connects to it, waiting up to timeout for one to show up.
The controller sends nothing until start is called.
Sourcepub async fn start(&self) -> Result<(), Error>
pub async fn start(&self) -> Result<(), Error>
Asks the controller to start sending data packets.
Sourcepub async fn stop(&self) -> Result<(), Error>
pub async fn stop(&self) -> Result<(), Error>
Asks the controller to stop sending data packets.
Sourcepub async fn packets(&self) -> Result<PacketStream, Error>
pub async fn packets(&self) -> Result<PacketStream, Error>
The packets the controller sends. The stream ends when the connection is lost on most
platforms; check is_connected if it goes quiet.
Sourcepub async fn battery_level(&self) -> Result<Option<u8>, Error>
pub async fn battery_level(&self) -> Result<Option<u8>, Error>
Battery charge in percent, if the controller reports it.
pub async fn is_connected(&self) -> bool
Sourcepub async fn disconnect(self) -> Result<(), Error>
pub async fn disconnect(self) -> Result<(), Error>
Stops the data and drops the connection.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Controller
impl !UnwindSafe for Controller
impl Forget for Controller
impl Freeze for Controllerwhere
*const ArcInner<SyncConnection> is !null: Freeze,
PhantomData<ArcInner<SyncConnection>>: Freeze,
&'static str: Freeze,
String: Freeze,
*const ArcInner<Mutex<HashMap<Uuid, ServiceInternal>>> is !null: Freeze,
PhantomData<ArcInner<Mutex<HashMap<Uuid, ServiceInternal>>>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
InternalBitFlags: Freeze,
*const LeafNode<Descriptor, SetValZST> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(Descriptor, SetValZST)>>: Freeze,
impl Move for Controller
impl Send for Controller
impl Sync for Controller
impl Unpin for Controller
impl UnsafeUnpin for Controllerwhere
*const ArcInner<SyncConnection> is !null: UnsafeUnpin,
PhantomData<ArcInner<SyncConnection>>: UnsafeUnpin,
&'static str: UnsafeUnpin,
String: UnsafeUnpin,
*const ArcInner<Mutex<HashMap<Uuid, ServiceInternal>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Mutex<HashMap<Uuid, ServiceInternal>>>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
InternalBitFlags: UnsafeUnpin,
*const LeafNode<Descriptor, SetValZST> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(Descriptor, SetValZST)>>: UnsafeUnpin,
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
Mutably borrows from an owned value. Read more