Skip to main content

Controller

Struct Controller 

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

A connected controller.

Implementations§

Source§

impl Controller

Source

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.

Source

pub fn name(&self) -> &str

The controller’s Bluetooth name, such as Gear VR Controller(1A2B).

Source

pub async fn send(&self, command: Command) -> Result<(), Error>

Sends a command.

Source

pub async fn start(&self) -> Result<(), Error>

Asks the controller to start sending data packets.

Source

pub async fn stop(&self) -> Result<(), Error>

Asks the controller to stop sending data packets.

Source

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.

Source

pub async fn battery_level(&self) -> Result<Option<u8>, Error>

Battery charge in percent, if the controller reports it.

Source

pub async fn is_connected(&self) -> bool

Source

pub async fn disconnect(self) -> Result<(), Error>

Stops the data and drops the connection.

Trait Implementations§

Source§

impl Debug for Controller

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Controller

§

impl !UnwindSafe for Controller

§

impl Forget for Controller

§

impl Freeze for Controller
where *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
where Arc<SyncConnection>: Send, &'static str: Send, String: Send, Arc<Mutex<HashMap<Uuid, ServiceInternal>>>: Send, RawVecInner: Send, InternalBitFlags: Send, NodeRef<Owned, Descriptor, SetValZST, LeafOrInternal>: Send, BoxRaw<(Descriptor, SetValZST)>: Send,

§

impl Sync for Controller
where Arc<SyncConnection>: Sync, String: Sync, Arc<Mutex<HashMap<Uuid, ServiceInternal>>>: Sync, RawVecInner: Sync, InternalBitFlags: Sync, NodeRef<Owned, Descriptor, SetValZST, LeafOrInternal>: Sync, BoxRaw<(Descriptor, SetValZST)>: Sync,

§

impl Unpin for Controller
where Arc<SyncConnection>: Unpin, &'static str: Unpin, String: Unpin, Arc<Mutex<HashMap<Uuid, ServiceInternal>>>: Unpin, *const u8 is !null: Unpin, InternalBitFlags: Unpin, *const LeafNode<Descriptor, SetValZST> is !null: Unpin, Box<(Descriptor, SetValZST)>: Unpin,

§

impl UnsafeUnpin for Controller
where *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> 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.