Skip to main content

Link

Trait Link 

Source
pub trait Link: Send + Sync {
    // Required methods
    fn state(&self) -> LinkState;
    fn usb_host(&self) -> bool;
    fn reach(&self) -> Reach;
    fn transceive(&self, command: &[u8]) -> Result<Vec<u8>, LinkError>;
    fn wait(&self, timeout: Duration);
    fn want(&self, wanted: bool);
}
Expand description

What carries APDUs between Sioul and a key held to the phone: the app’s, over Android’s NFC; a stand-in in tests.

Required Methods§

Source

fn state(&self) -> LinkState

Whether the phone can reach a key held against it now (NFC).

Source

fn usb_host(&self) -> bool

Whether the phone takes a key plugged into its USB-C port (USB host).

Source

fn reach(&self) -> Reach

The key in reach now: plugged in first, else held.

Source

fn transceive(&self, command: &[u8]) -> Result<Vec<u8>, LinkError>

One APDU to the key held; its answer, status words included.

Source

fn wait(&self, timeout: Duration)

Waits at most timeout for a key to be held or plugged in.

Source

fn want(&self, wanted: bool)

A key is wanted now, or no longer: while it is, the phone reads keys in reader mode, ahead of other apps, and asks Android, once for each time it is plugged in, to let Sioul use a key plugged in; no longer, the key held is let go (Android hands it to no other app until it leaves the field), reader mode ends, and the key plugged in is powered off and given back.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§