verify/
verify.rs

1use libfprint_rs::{FpContext, FpDevice, FpPrint};
2
3fn main() {
4    // Get devices
5    let ctx = FpContext::new();
6    let devices = ctx.devices();
7    let dev = devices.first().unwrap();
8    dev.open_sync(None).unwrap();
9
10    // Create a template print
11    let template = FpPrint::new(dev);
12    let enrolled_print = dev
13        .enroll_sync(template, None, Some(progress_cb), None)
14        .unwrap();
15
16    // New print where we will store the next print
17    let mut new_print = FpPrint::new(dev);
18
19    // Verify if the next print matches the previously enrolled print
20    let matched = dev
21        .verify_sync(
22            &enrolled_print,
23            None,
24            Some(match_cb),
25            None,
26            Some(&mut new_print),
27        )
28        .unwrap();
29    if matched {
30        println!("Matched again");
31    }
32}
33
34pub fn progress_cb(
35    _device: &FpDevice,
36    enroll_stage: i32,
37    _print: Option<FpPrint>,
38    _error: Option<glib::Error>,
39    _: &Option<()>,
40) {
41    println!("Enroll stage: {}", enroll_stage);
42}
43
44pub fn match_cb(
45    _device: &FpDevice,
46    matched_print: Option<FpPrint>,
47    _print: FpPrint,
48    _error: Option<glib::Error>,
49    _data: &Option<()>,
50) {
51    if matched_print.is_some() {
52        println!("Matched");
53    } else {
54        println!("Not matched");
55    }
56}