Skip to main content

Readers

Trait Readers 

Source
pub trait Readers: Send + Sync {
    // Required methods
    fn present(&self) -> Result<Vec<String>, CardError>;
    fn visit(
        &self,
        visit: &mut dyn FnMut(&mut dyn Card) -> Visit,
    ) -> Result<Visited, CardError>;

    // Provided methods
    fn wait_change(&self, timeout: Duration) { ... }
    fn taps(&self) -> bool { ... }
    fn want(&self, _wanted: bool) { ... }
    fn by_cable(&self) -> bool { ... }
    fn reach_note(&self) -> Option<CardError> { ... }
}
Expand description

Where Sioul finds security keys: the system’s smart card service on a computer, a phone’s NFC or USB, a software stand-in in tests.

Required Methods§

Source

fn present(&self) -> Result<Vec<String>, CardError>

The readers holding a key now, by name, without opening any: to see a key go away.

Source

fn visit( &self, visit: &mut dyn FnMut(&mut dyn Card) -> Visit, ) -> Result<Visited, CardError>

Opens each key present in turn, in shared mode, and gives it to visit until visit is done; each is closed afterwards, which resets it.

Provided Methods§

Source

fn wait_change(&self, timeout: Duration)

Waits for the readers to change, timeout at most: a computer looks again after it; a phone wakes as soon as a key is held to it.

Source

fn taps(&self) -> bool

Whether a key is used in one tap (a phone, over NFC): its PIN asked first, from what Sioul knows of it, then the key read, given its PIN and used while it is held, never read on its own beforehand.

Source

fn want(&self, _wanted: bool)

A key is wanted now, or no longer: a phone reads keys (NFC’s reader mode, ahead of other apps) only while Sioul asks for one, in front.

Source

fn by_cable(&self) -> bool

Whether the key in reach now, or the last one used, came by cable (a phone’s USB-C port): its touch is asked as on a computer, and it is unplugged rather than moved away. A computer’s readers say no: their words are the computer’s.

Source

fn reach_note(&self) -> Option<CardError>

How keys can come now, when one way is missing: a phone without NFC (NoNfc) or with NFC off (NfcOff) still takes a key plugged in.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§