Struct libfprint_rs::FpContext

source ·
pub struct FpContext { /* private fields */ }
Expand description

This struct allows you to discover fingerprint scanning hardware. This is the starting point when integrating libfprint-rs into your software.

Implementations§

source§

impl FpContext

source

pub fn new() -> FpContext

Create a new FpContext

Examples:
use libfprint_rs::FpContext;

let context = FpContext::new();
Examples found in repository?
examples/verify.rs (line 6)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
fn main() {
    let context = FpContext::new();
    let devices = context.get_devices();

    let dev = match devices.iter().next() {
        Some(dev) => dev,
        None => {
            eprintln!("No devices detected.");
            std::process::exit(1);
        }
    };
    let print_matched = verify(dev).unwrap();

    if print_matched {
        println!("Print matched");
    } else {
        println!("Prints don't match!!");
    }
}
More examples
Hide additional examples
examples/enroll.rs (line 4)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
fn main() {
    let context = FpContext::new();
    let devices = context.get_devices();

    let dev = match devices.iter().next() {
        Some(dev) => dev,
        None => {
            eprintln!("No devices detected.");
            std::process::exit(1);
        }
    };

    let print = enroll(dev);
    if let Ok(print) = print {
        let username = print.get_username().unwrap();
        println!("User provided username: \"{}\"", username);
    }
}
source

pub fn enumerate(&self)

Enumerate all the devices connected to the system

This function will enumerate all the devices connected to the system and add them to the context.

source

pub fn get_devices<'a>(&'a self) -> DeviceList<'a>

Get the list of devices connected to the system

Examples:
use libfprint_rs::FpContext;

let context = FpContext::new();
let devices = context.get_devices();
Examples found in repository?
examples/verify.rs (line 7)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
fn main() {
    let context = FpContext::new();
    let devices = context.get_devices();

    let dev = match devices.iter().next() {
        Some(dev) => dev,
        None => {
            eprintln!("No devices detected.");
            std::process::exit(1);
        }
    };
    let print_matched = verify(dev).unwrap();

    if print_matched {
        println!("Print matched");
    } else {
        println!("Prints don't match!!");
    }
}
More examples
Hide additional examples
examples/enroll.rs (line 5)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
fn main() {
    let context = FpContext::new();
    let devices = context.get_devices();

    let dev = match devices.iter().next() {
        Some(dev) => dev,
        None => {
            eprintln!("No devices detected.");
            std::process::exit(1);
        }
    };

    let print = enroll(dev);
    if let Ok(print) = print {
        let username = print.get_username().unwrap();
        println!("User provided username: \"{}\"", username);
    }
}

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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.