pub struct Device<D: HidDevice> { /* private fields */ }
Expand description
A connected CTAPHID device.
Implementations
sourceimpl<D: HidDevice> Device<D>
impl<D: HidDevice> Device<D>
sourcepub fn new(device: D, device_info: D::Info) -> Result<Self, Error>
pub fn new(device: D, device_info: D::Info) -> Result<Self, Error>
Connects to a HID device, assuming that it is a CTAPHID device, and initializes the
communication channel using the default Options
.
sourcepub fn with_options(
device: D,
device_info: D::Info,
options: Options
) -> Result<Self, Error>
pub fn with_options(
device: D,
device_info: D::Info,
options: Options
) -> Result<Self, Error>
Connects to a HID device, assuming that it is a CTAPHID device, and initializes the communication channel using the given options.
sourcepub fn ping(&self, data: &[u8]) -> Result<(), Error>
pub fn ping(&self, data: &[u8]) -> Result<(), Error>
Pings the device sending the given data and checks that it sends the same data back.
If the data returned by the device does not match the sent data,
CommandError::InvalidPingData
is returned.
sourcepub fn wink(&self) -> Result<(), Error>
pub fn wink(&self) -> Result<(), Error>
Executes the wink command, causing a vendor-defined action that provides some visual or audible identification of a particular authenticator.
sourcepub fn ctap1(&self, data: &[u8]) -> Result<Vec<u8>, Error>
pub fn ctap1(&self, data: &[u8]) -> Result<Vec<u8>, Error>
Sends the given CTAP1/U2F command to the device and returns the response.
sourcepub fn ctap2(&self, command: u8, data: &[u8]) -> Result<Vec<u8>, Error>
pub fn ctap2(&self, command: u8, data: &[u8]) -> Result<Vec<u8>, Error>
Sends the given CTAP2/CBOR command and data to the device and returns the response status and data.
sourcepub fn lock(&self, duration: Duration) -> Result<(), Error>
pub fn lock(&self, duration: Duration) -> Result<(), Error>
Locks the device for the given duration to the current channel.
The duration is truncated to whole seconds and capped at ten seconds.
sourcepub fn vendor_command(
&self,
command: VendorCommand,
data: &[u8]
) -> Result<Vec<u8>, Error>
pub fn vendor_command(
&self,
command: VendorCommand,
data: &[u8]
) -> Result<Vec<u8>, Error>
Executes the given vendor-specific command with the given data.
sourcepub fn protocol_version(&self) -> u8
pub fn protocol_version(&self) -> u8
Returns the protocol version implemented by this device.
sourcepub fn device_version(&self) -> DeviceVersion
pub fn device_version(&self) -> DeviceVersion
Returns the version of this device.
sourcepub fn capabilities(&self) -> Capabilities
pub fn capabilities(&self) -> Capabilities
Returns the capabilities of this device.
Trait Implementations
Auto Trait Implementations
impl<D> !RefUnwindSafe for Device<D>
impl<D> Send for Device<D> where
D: Send,
<D as Device>::Info: Send,
impl<D> !Sync for Device<D>
impl<D> Unpin for Device<D> where
D: Unpin,
<D as Device>::Info: Unpin,
impl<D> UnwindSafe for Device<D> where
D: UnwindSafe,
<D as Device>::Info: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more