pub enum GenericConnection {
Bluetooth(BluetoothConnection),
Serial(SerialConnection),
}
Variants§
Bluetooth(BluetoothConnection)
Serial(SerialConnection)
Implementations§
Source§impl GenericConnection
impl GenericConnection
Sourcepub fn is_bluetooth(&self) -> bool
pub fn is_bluetooth(&self) -> bool
Returns whether the connection is over bluetooth.
Sourcepub fn is_controller(&self) -> bool
pub fn is_controller(&self) -> bool
Returns whether the connection is a controller.
Sourcepub async fn is_paired(&self) -> Result<bool, GenericError>
pub async fn is_paired(&self) -> Result<bool, GenericError>
Checks if the connection is paired. If the connection is not over bluetooth, this function will return an error.
Sourcepub async fn request_pairing(&mut self) -> Result<(), GenericError>
pub async fn request_pairing(&mut self) -> Result<(), GenericError>
Requests pairing with the device.
§Errors
If the connection is not over bluetooth, this function will return an error. This function will also error if there is a communication error while requesting pairing.
Sourcepub async fn authenticate_pairing(
&mut self,
pin: [u8; 4],
) -> Result<(), GenericError>
pub async fn authenticate_pairing( &mut self, pin: [u8; 4], ) -> Result<(), GenericError>
Attempts to authenticate the pairing request with the given pin. If the connection is not over bluetooth, this function will return an error.
Trait Implementations§
Source§impl Connection for GenericConnection
impl Connection for GenericConnection
type Error = GenericError
fn connection_type(&self) -> ConnectionType
Source§async fn recv<P: Decode + CheckHeader>(
&mut self,
timeout: Duration,
) -> Result<P, GenericError>
async fn recv<P: Decode + CheckHeader>( &mut self, timeout: Duration, ) -> Result<P, GenericError>
Receives a packet.
Source§async fn read_user(&mut self, buf: &mut [u8]) -> Result<usize, GenericError>
async fn read_user(&mut self, buf: &mut [u8]) -> Result<usize, GenericError>
Read user program output.
Source§async fn write_user(&mut self, buf: &[u8]) -> Result<usize, GenericError>
async fn write_user(&mut self, buf: &[u8]) -> Result<usize, GenericError>
Write to user program stdio.
Source§impl From<BluetoothConnection> for GenericConnection
impl From<BluetoothConnection> for GenericConnection
Source§fn from(c: BluetoothConnection) -> Self
fn from(c: BluetoothConnection) -> Self
Converts to this type from the input type.
Source§impl From<SerialConnection> for GenericConnection
impl From<SerialConnection> for GenericConnection
Source§fn from(c: SerialConnection) -> Self
fn from(c: SerialConnection) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for GenericConnection
impl !RefUnwindSafe for GenericConnection
impl Send for GenericConnection
impl !Sync for GenericConnection
impl Unpin for GenericConnection
impl !UnwindSafe for GenericConnection
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