### Full Enrollment Flow Source: https://context7.com/mushonnip/fingerprint-sensor/llms.txt Complete example showing the two-scan enrollment workflow with error handling at every step. ```APIDOC ## Full Enrollment Flow Complete example showing the two-scan enrollment workflow with error handling at every step: ```rust use fingerprint_sensor::{ DeviceBuilder, BADLOCATION, ENROLLMISMATCH, FEATUREFAIL, FLASHERR, IMAGEFAIL, IMAGEMESS, INVALIDIMAGE, NOFINGER, OK, }; use std::thread::sleep; use std::time::Duration; fn enroll_finger(location: u16, device: &mut fingerprint_sensor::Device) -> std::io::Result<()> { for scan in 1u8..=2 { if scan == 1 { println!("Place finger on sensor..."); } else { println!("Place the same finger again..."); } // Wait for a clean image loop { match device.get_image()? { OK => { println!("Image captured"); break; } NOFINGER => print!("."), IMAGEFAIL => return Err(std::io::Error::new(std::io::ErrorKind::Other, "Imaging error")), other => return Err(std::io::Error::new(std::io::ErrorKind::Other, format!("get_image: {:#X}", other))), } } // Convert image to template in slot `scan` match device.image_2_tz(scan)? { OK => println!("Templated"), IMAGEMESS => return Err(std::io::Error::new(std::io::ErrorKind::Other, "Image too messy")), FEATUREFAIL => return Err(std::io::Error::new(std::io::ErrorKind::Other, "Feature extraction failed")), INVALIDIMAGE => return Err(std::io::Error::new(std::io::ErrorKind::Other, "Invalid image")), other => return Err(std::io::Error::new(std::io::ErrorKind::Other, format!("image_2_tz: {:#X}", other))), } if scan == 1 { println!("Remove finger"); sleep(Duration::from_secs(1)); } } // Merge both template slots match device.create_model()? { OK => println!("Model created"), ENROLLMISMATCH => return Err(std::io::Error::new(std::io::ErrorKind::Other, "Prints did not match")), other => return Err(std::io::Error::new(std::io::ErrorKind::Other, format!("create_model: {:#X}", other))), } // Persist to sensor flash match device.store_model(location, 1)? { OK => println!("Stored at location {}", location), BADLOCATION => return Err(std::io::Error::new(std::io::ErrorKind::Other, "Bad location")), FLASHERR => return Err(std::io::Error::new(std::io::ErrorKind::Other, "Flash error")), other => return Err(std::io::Error::new(std::io::ErrorKind::Other, format!("store_model: {:#X}", other))), } Ok(()) } fn main() -> std::io::Result<()> { let mut device = DeviceBuilder::new(vec![0xFF; 4], vec![0; 4]) .uart_from_port("/dev/ttyUSB0", 57600)? .build()?; enroll_finger(0, &mut device)?; // enroll at index 0 Ok(()) } ``` ``` -------------------------------- ### Install fingerprint-sensor Crate Source: https://context7.com/mushonnip/fingerprint-sensor/llms.txt Add the fingerprint-sensor library to your project's dependencies in Cargo.toml or use the Cargo CLI. ```toml [dependencies] fingerprint-sensor = "0.1.2" ``` ```bash cargo add fingerprint-sensor ``` -------------------------------- ### DeviceBuilder - Constructing a Sensor Connection Source: https://context7.com/mushonnip/fingerprint-sensor/llms.txt Demonstrates how to initialize and build a connection to the fingerprint sensor using DeviceBuilder. It covers setting the address and password, opening the UART port, optionally enabling debug output, and verifying the connection. ```APIDOC ## DeviceBuilder::new ### Description Initializes a builder with the sensor's address and password bytes. ### Method `DeviceBuilder::new(address: Vec, password: Vec) -> DeviceBuilder` ### Parameters - **address** (Vec) - The unique address of the sensor. - **password** (Vec) - The password for authenticating with the sensor. ## DeviceBuilder::uart_from_port ### Description Opens the serial port for communication with the sensor. ### Method `uart_from_port(port_name: &str, baud_rate: u32) -> Result` ### Parameters - **port_name** (&str) - The name of the serial port (e.g., \"/dev/ttyUSB0\"). - **baud_rate** (u32) - The communication speed for the serial port. ### Returns A `Result` containing a configured `DeviceBuilder` on success, or an `std::io::Error` on failure. ## DeviceBuilder::enable_debug ### Description Enables debug output, printing raw hex packets to stdout. ### Method `enable_debug(self) -> DeviceBuilder` ## DeviceBuilder::build ### Description Verifies the password and reads system parameters from the sensor, returning a connected `Device`. ### Method `build(self) -> Result` ### Returns A `Result` containing the connected `Device` on success, or an `std::io::Error` on failure. ### Example ```rust use fingerprint_sensor::DeviceBuilder; fn main() -> std::io::Result<()> { let address = vec![0xFF, 0xFF, 0xFF, 0xFF]; // default sensor address let password = vec![0x00, 0x00, 0x00, 0x00]; // default password let mut device = DeviceBuilder::new(address, password) .uart_from_port("/dev/ttyUSB0", 57600)? // opens serial port with 1s timeout .enable_debug() // optional: prints packet bytes .build()?; // verifies password + reads sys params println!("Library size: {:?}", device.library_size); Ok(()) } ``` ``` -------------------------------- ### Full Fingerprint Enrollment Flow in Rust Source: https://context7.com/mushonnip/fingerprint-sensor/llms.txt Demonstrates a two-scan enrollment workflow with comprehensive error handling at each step, including image capture, template conversion, model creation, and storage. ```rust use fingerprint_sensor::{ DeviceBuilder, BADLOCATION, ENROLLMISMATCH, FEATUREFAIL, FLASHERR, IMAGEFAIL, IMAGEMESS, INVALIDIMAGE, NOFINGER, OK, }; use std::thread::sleep; use std::time::Duration; fn enroll_finger(location: u16, device: &mut fingerprint_sensor::Device) -> std::io::Result<()> { for scan in 1u8..=2 { if scan == 1 { println!("Place finger on sensor..."); } else { println!("Place the same finger again..."); } // Wait for a clean image loop { match device.get_image()? { OK => { println!("Image captured"); break; } NOFINGER => print!("."), IMAGEFAIL => return Err(std::io::Error::new(std::io::ErrorKind::Other, "Imaging error")), other => return Err(std::io::Error::new(std::io::ErrorKind::Other, format!("get_image: {:#X}", other))), } } // Convert image to template in slot `scan` match device.image_2_tz(scan)? { OK => println!("Templated"), IMAGEMESS => return Err(std::io::Error::new(std::io::ErrorKind::Other, "Image too messy")), FEATUREFAIL => return Err(std::io::Error::new(std::io::ErrorKind::Other, "Feature extraction failed")), INVALIDIMAGE => return Err(std::io::Error::new(std::io::ErrorKind::Other, "Invalid image")), other => return Err(std::io::Error::new(std::io::ErrorKind::Other, format!("image_2_tz: {:#X}", other))), } if scan == 1 { println!("Remove finger"); sleep(Duration::from_secs(1)); } } // Merge both template slots match device.create_model()? { OK => println!("Model created"), ENROLLMISMATCH => return Err(std::io::Error::new(std::io::ErrorKind::Other, "Prints did not match")), other => return Err(std::io::Error::new(std::io::ErrorKind::Other, format!("create_model: {:#X}", other))), } // Persist to sensor flash match device.store_model(location, 1)? { OK => println!("Stored at location {}", location), BADLOCATION => return Err(std::io::Error::new(std::io::ErrorKind::Other, "Bad location")), FLASHERR => return Err(std::io::Error::new(std::io::ErrorKind::Other, "Flash error")), other => return Err(std::io::Error::new(std::io::ErrorKind::Other, format!("store_model: {:#X}", other))), } Ok(()) } fn main() -> std::io::Result<()> { let mut device = DeviceBuilder::new(vec![0xFF; 4], vec![0; 4]) .uart_from_port("/dev/ttyUSB0", 57600)? .build()?; enroll_finger(0, &mut device)?; // enroll at index 0 Ok(()) } ``` -------------------------------- ### Build Device Connection with DeviceBuilder Source: https://context7.com/mushonnip/fingerprint-sensor/llms.txt Initialize a DeviceBuilder with sensor address and password, configure the UART connection, and build the device object. Debugging can be enabled to print raw packets. ```rust use fingerprint_sensor::DeviceBuilder; fn main() -> std::io::Result<()> { let address = vec![0xFF, 0xFF, 0xFF, 0xFF]; // default sensor address let password = vec![0x00, 0x00, 0x00, 0x00]; // default password let mut device = DeviceBuilder::new(address, password) .uart_from_port("/dev/ttyUSB0", 57600)? // opens serial port with 1s timeout .enable_debug() // optional: prints packet bytes .build()?; // verifies password + reads sys params println!("Library size: {:?}", device.library_size); // Output: Library size: Some(162) Ok(()) } ``` -------------------------------- ### create_model Source: https://context7.com/mushonnip/fingerprint-sensor/llms.txt Combines two character buffer templates into a single merged fingerprint model. Returns ENROLLMISMATCH if the templates do not match. ```APIDOC ## `create_model` — Merge Two Templates into a Fingerprint Model Combines the templates stored in character buffer slots 1 and 2 into a single merged fingerprint model ready for storage. Returns `ENROLLMISMATCH` if the two scans did not come from the same finger. ### Method ```rust fn create_model(&mut self) -> Result ``` ### Returns - `OK`: Model created successfully. - `ENROLLMISMATCH`: The two scans did not originate from the same finger. - Other error codes as defined by the library. ``` -------------------------------- ### Create Fingerprint Model Source: https://context7.com/mushonnip/fingerprint-sensor/llms.txt Combines two fingerprint templates from character buffer slots 1 and 2 into a single model. Returns ENROLLMISMATCH if the scans are not from the same finger. ```rust use fingerprint_sensor::{DeviceBuilder, ENROLLMISMATCH, OK}; fn main() -> std::io::Result<()> { let mut device = DeviceBuilder::new(vec![0xFF; 4], vec![0; 4]) .uart_from_port("/dev/ttyUSB0", 57600)? .build()?; // Assumes slots 1 and 2 have been populated via image_2_tz match device.create_model()? { OK => println!("Model created successfully"), ENROLLMISMATCH => eprintln!("Fingerprints did not match — use the same finger for both scans"), other => eprintln!("Error creating model: {:#X}", other), } Ok(()) } ``` -------------------------------- ### Search Fingerprint Library Source: https://context7.com/mushonnip/fingerprint-sensor/llms.txt Converts the current image buffer to a template and searches the entire flash library for a matching fingerprint. Populates device.finger_id and device.confidence on success. ```rust use fingerprint_sensor::{DeviceBuilder, NOFINGER, OK}; fn main() -> std::io::Result<()> { let mut device = DeviceBuilder::new(vec![0xFF; 4], vec![0; 4]) .uart_from_port("/dev/ttyUSB0", 57600)? .build()?; // First capture and template the image device.get_image()?; device.image_2_tz(1)?; match device.finger_search()? { OK => println!( "Match found! ID: {}, Confidence: {}", device.finger_id, // e.g. 5 device.confidence // e.g. 172 (higher = better match) ), other => eprintln!("No match found, status: {:#X}", other), } Ok(()) } ``` -------------------------------- ### Add fingerprint-sensor Crate Source: https://github.com/mushonnip/fingerprint-sensor/blob/main/README.md Use this command to add the fingerprint-sensor library to your Rust project dependencies. ```bash cargo add fingerprint-sensor ``` -------------------------------- ### get_image — Capture a Fingerprint Image Source: https://context7.com/mushonnip/fingerprint-sensor/llms.txt Instructs the sensor to capture a live fingerprint image. It returns status codes indicating success, no finger detected, or imaging errors. ```APIDOC ## Device::get_image ### Description Instructs the sensor to capture a live fingerprint image from the scanner surface and hold it in its image buffer. Returns `OK` on success, `NOFINGER` if no finger is detected, or `IMAGEFAIL` / `IMAGEMESS` on imaging errors. ### Method `get_image(&mut self) -> Result` ### Returns - `Ok(status)`: Returns a status code. `OK` (0x00) for success, `NOFINGER` (0x01) if no finger is detected, `IMAGEFAIL` (0x02), or `IMAGEMESS` (0x03) on imaging errors. - `Err(e)`: An `std::io::Error` if communication fails. ### Example ```rust use fingerprint_sensor::{DeviceBuilder, NOFINGER, OK}; use std::thread::sleep; use std::time::Duration; fn main() -> std::io::Result<()> { let mut device = DeviceBuilder::new(vec![0xFF; 4], vec![0; 4]) .uart_from_port("/dev/ttyUSB0", 57600)? .build()?; println!("Place finger on sensor..."); loop { match device.get_image()? { OK => { println!("Image captured successfully"); break; } NOFINGER => { print!("."); sleep(Duration::from_millis(100)); } other => { eprintln!("Imaging error, status: {:#X}", other); break; } } } Ok(()) } ``` ``` -------------------------------- ### Count Stored Fingerprint Templates Source: https://context7.com/mushonnip/fingerprint-sensor/llms.txt Send a TEMPLATECOUNT command to the sensor to retrieve the number of stored fingerprint templates. Check the status for success or errors. ```rust use fingerprint_sensor::{DeviceBuilder, OK}; fn main() -> std::io::Result<()> { let mut device = DeviceBuilder::new(vec![0xFF; 4], vec![0; 4]) .uart_from_port("/dev/ttyUSB0", 57600)? .build()?; match device.count_templates() { Ok(status) if status == OK => { println!("Templates stored: {}", device.template_count); // Output: Templates stored: 3 } Ok(_) => eprintln!("Sensor returned an error status"), Err(e) => eprintln!("IO error: {}", e), } Ok(()) } ``` -------------------------------- ### Convert Image to Template Slot Source: https://context7.com/mushonnip/fingerprint-sensor/llms.txt Converts the current image in the sensor's buffer into a feature template and stores it in either slot 1 or slot 2. This is a prerequisite for creating a model. ```rust use fingerprint_sensor::{DeviceBuilder, FEATUREFAIL, IMAGEMESS, INVALIDIMAGE, OK}; fn main() -> std::io::Result<()> { let mut device = DeviceBuilder::new(vec![0xFF; 4], vec![0; 4]) .uart_from_port("/dev/ttyUSB0", 57600)? .build()?; // After a successful get_image(), convert into slot 1 match device.image_2_tz(1)? { OK => println!("Templated into slot 1"), IMAGEMESS => eprintln!("Image too messy, ask user to re-place finger"), FEATUREFAIL => eprintln!("Could not extract features"), INVALIDIMAGE => eprintln!("Invalid image data"), other => eprintln!("Unknown status: {:#X}", other), } Ok(()) } ``` -------------------------------- ### finger_search Source: https://context7.com/mushonnip/fingerprint-sensor/llms.txt Converts the current image buffer to a template and searches the entire flash library for a matching fingerprint. Populates finger_id and confidence on success. ```APIDOC ## `finger_search` — Search All Templates for a Match Converts the current image buffer to a template and searches the entire flash library for a matching fingerprint. On success, populates `device.finger_id` with the matched template's location index and `device.confidence` with the match confidence score. ### Method ```rust fn finger_search(&mut self) -> Result ``` ### Returns - `OK`: A matching fingerprint was found. - Other error codes indicate no match or an error during the search process. ``` -------------------------------- ### image_2_tz — Convert Image to Template Slot Source: https://context7.com/mushonnip/fingerprint-sensor/llms.txt Converts the current image in the sensor's buffer into a feature template and stores it in either slot 1 or slot 2. Both slots must be populated before creating a model. ```APIDOC ## Device::image_2_tz ### Description Converts the image currently in the sensor's image buffer into a feature template and stores it in one of two internal character buffer slots (slot `1` or slot `2`). Both slots must be populated before calling `create_model`. ### Method `image_2_tz(&mut self, tz_num: u8) -> Result` ### Parameters - **tz_num** (u8) - The target template buffer slot (1 or 2). ### Returns - `Ok(status)`: Returns `OK` (0x00) on success. Other possible status codes include `IMAGEMESS` (0x01), `FEATUREFAIL` (0x02), `INVALIDIMAGE` (0x04). - `Err(e)`: An `std::io::Error` if communication fails. ### Example ```rust use fingerprint_sensor::{DeviceBuilder, FEATUREFAIL, IMAGEMESS, INVALIDIMAGE, OK}; fn main() -> std::io::Result<()> { let mut device = DeviceBuilder::new(vec![0xFF; 4], vec![0; 4]) .uart_from_port("/dev/ttyUSB0", 57600)? .build()?; // After a successful get_image(), convert into slot 1 match device.image_2_tz(1)? { OK => println!("Templated into slot 1"), IMAGEMESS => eprintln!("Image too messy, ask user to re-place finger"), FEATUREFAIL => eprintln!("Could not extract features"), INVALIDIMAGE => eprintln!("Invalid image data"), other => eprintln!("Unknown status: {:#X}", other), } Ok(()) } ``` ``` -------------------------------- ### store_model Source: https://context7.com/mushonnip/fingerprint-sensor/llms.txt Writes the merged model from the sensor's buffer into a specific flash memory location. Returns BADLOCATION or FLASHERR on failure. ```APIDOC ## `store_model` — Save Model to Sensor Flash Writes the merged model from the sensor's buffer into a specific flash memory location (0-indexed up to `library_size - 1`). `slot` should be `1` (the primary character buffer). Returns `BADLOCATION` if the index is out of range, or `FLASHERR` on a write failure. ### Method ```rust fn store_model(&mut self, location: u16, slot: u16) -> Result ``` ### Parameters - **location** (u16) - The flash memory index to store the model. - **slot** (u16) - The character buffer slot to use (typically 1). ### Returns - `OK`: Fingerprint stored successfully. - `BADLOCATION`: The provided `location` index is out of range. - `FLASHERR`: An error occurred during the flash write operation. - Other error codes as defined by the library. ``` -------------------------------- ### Refresh System Parameters with Rust Source: https://context7.com/mushonnip/fingerprint-sensor/llms.txt Re-reads sensor system parameters and updates Device fields. Called automatically during build(), but can be called again to refresh the state. ```rust use fingerprint_sensor::DeviceBuilder; fn main() -> std::io::Result<()> { let mut device = DeviceBuilder::new(vec![0xFF; 4], vec![0; 4]) .uart_from_port("/dev/ttyUSB0", 57600)? .build()?; device.read_sysparam()?; println!("Library size: {:?}", device.library_size); // Some(162) println!("Template count: {}", device.template_count); Ok(()) } ``` -------------------------------- ### count_templates — Query Stored Template Count Source: https://context7.com/mushonnip/fingerprint-sensor/llms.txt Sends a TEMPLATECOUNT command to the sensor to retrieve the number of currently stored fingerprint templates. The result is populated in `device.template_count`. ```APIDOC ## Device::count_templates ### Description Sends a `TEMPLATECOUNT` command to the sensor and populates `device.template_count` with the number of fingerprint templates currently stored in flash memory. ### Method `count_templates(&mut self) -> Result` ### Returns - `Ok(status)`: Returns `OK` (0x00) on success, with the template count available in `self.template_count`. - `Err(e)`: An `std::io::Error` if communication fails. ### Example ```rust use fingerprint_sensor::{DeviceBuilder, OK}; fn main() -> std::io::Result<()> { let mut device = DeviceBuilder::new(vec![0xFF; 4], vec![0; 4]) .uart_from_port("/dev/ttyUSB0", 57600)? .build()?; match device.count_templates() { Ok(status) if status == OK => { println!("Templates stored: {}", device.template_count); } Ok(_) => eprintln!("Sensor returned an error status"), Err(e) => eprintln!("IO error: {}", e), } Ok(()) } ``` ``` -------------------------------- ### Erase All Fingerprint Templates Source: https://context7.com/mushonnip/fingerprint-sensor/llms.txt Sends the DELETEALL command to wipe all fingerprint templates from the sensor's flash memory. This operation is irreversible. ```rust use fingerprint_sensor::{DeviceBuilder, OK}; fn main() -> std::io::Result<()> { let mut device = DeviceBuilder::new(vec![0xFF; 4], vec![0; 4]) .uart_from_port("/dev/ttyUSB0", 57600)? .build()?; match device.delete_all()? { OK => println!("All templates erased"), other => eprintln!("Erase failed, status: {:#X}", other), } Ok(()) } ``` -------------------------------- ### Read System Parameters Source: https://context7.com/mushonnip/fingerprint-sensor/llms.txt Re-reads sensor system parameters and updates the Device fields: status_register, system_id, library_size, security_level, data_packet_size, and baudrate. Called automatically during build(), but can be called again to refresh the state. ```APIDOC ## `read_sysparam` — Refresh System Parameters Re-reads sensor system parameters and updates the `Device` fields: `status_register`, `system_id`, `library_size`, `security_level`, `data_packet_size`, and `baudrate`. Called automatically during `build()`, but can be called again to refresh the state. ```rust use fingerprint_sensor::DeviceBuilder; fn main() -> std::io::Result<()> { let mut device = DeviceBuilder::new(vec![0xFF; 4], vec![0; 4]) .uart_from_port("/dev/ttyUSB0", 57600)? .build()?; device.read_sysparam()?; println!("Library size: {:?}", device.library_size); // Some(162) println!("Template count: {}", device.template_count); Ok(()) } ``` ``` -------------------------------- ### Capture Fingerprint Image Source: https://context7.com/mushonnip/fingerprint-sensor/llms.txt Instructs the sensor to capture a fingerprint image. It loops until an image is successfully captured (OK), no finger is detected (NOFINGER), or an imaging error occurs. ```rust use fingerprint_sensor::{DeviceBuilder, NOFINGER, OK}; use std::thread::sleep; use std::time::Duration; fn main() -> std::io::Result<()> { let mut device = DeviceBuilder::new(vec![0xFF; 4], vec![0; 4]) .uart_from_port("/dev/ttyUSB0", 57600)? .build()?; println!("Place finger on sensor..."); loop { match device.get_image()? { OK => { println!("Image captured successfully"); break; } NOFINGER => { print!("."); sleep(Duration::from_millis(100)); } other => { eprintln!("Imaging error, status: {:#X}", other); break; } } } Ok(()) } ``` -------------------------------- ### Store Fingerprint Model Source: https://context7.com/mushonnip/fingerprint-sensor/llms.txt Writes the merged fingerprint model from the sensor's buffer to a specific flash memory location. Use slot 1 for the primary character buffer. Returns BADLOCATION or FLASHERR on failure. ```rust use fingerprint_sensor::{DeviceBuilder, BADLOCATION, FLASHERR, OK}; fn main() -> std::io::Result<()> { let mut device = DeviceBuilder::new(vec![0xFF; 4], vec![0; 4]) .uart_from_port("/dev/ttyUSB0", 57600)? .build()?; let location: u16 = 5; // store at index 5 match device.store_model(location, 1)? { OK => println!("Fingerprint stored at location {}", location), BADLOCATION => eprintln!("Invalid storage location: {}", location), FLASHERR => eprintln!("Flash write failed"), other => eprintln!("Error: {:#X}", other), } Ok(()) } ``` -------------------------------- ### delete_all Source: https://context7.com/mushonnip/fingerprint-sensor/llms.txt Wipes all fingerprint templates from the sensor's flash memory. This operation is irreversible. ```APIDOC ## `delete_all` — Erase All Stored Templates Sends the `DELETEALL` command to wipe every fingerprint template from the sensor's flash memory. This is irreversible. ### Method ```rust fn delete_all(&mut self) -> Result ``` ### Returns - `OK`: All templates were erased successfully. - Other error codes indicate a failure during the erase process. ``` -------------------------------- ### finger_fast_search Source: https://context7.com/mushonnip/fingerprint-sensor/llms.txt Performs a high-speed search of the fingerprint library. Refreshes system parameters before searching and populates finger_id and confidence on success. ```APIDOC ## `finger_fast_search` — High-Speed Template Search Performs the same library search as `finger_search` but using the sensor's high-speed search command (`HISPEEDSEARCH`). Also refreshes system parameters before searching. Populates `device.finger_id` and `device.confidence` identically to `finger_search`. ### Method ```rust fn finger_fast_search(&mut self) -> Result ``` ### Returns - `OK`: A matching fingerprint was found. - Other error codes indicate no match or an error during the search process. ``` -------------------------------- ### Fast Fingerprint Search Source: https://context7.com/mushonnip/fingerprint-sensor/llms.txt Performs a high-speed search of the fingerprint library using the HISPEEDSEARCH command. Refreshes system parameters before searching and populates device.finger_id and device.confidence. ```rust use fingerprint_sensor::{DeviceBuilder, OK}; fn main() -> std::io::Result<()> { let mut device = DeviceBuilder::new(vec![0xFF; 4], vec![0; 4]) .uart_from_port("/dev/ttyUSB0", 57600)? .build()?; device.get_image()?; device.image_2_tz(1)?; match device.finger_fast_search()? { OK => println!( "Fast match — ID: {}, Confidence: {}", device.finger_id, device.confidence ), other => eprintln!("No match, status: {:#X}", other), } Ok(()) } ``` -------------------------------- ### delete_model Source: https://context7.com/mushonnip/fingerprint-sensor/llms.txt Removes a specific fingerprint template from the sensor's flash memory at the given location index. ```APIDOC ## `delete_model` — Delete a Specific Template Removes the fingerprint template stored at a given flash location index. Useful for revoking access for a specific enrolled user. ### Method ```rust fn delete_model(&mut self, location: u16) -> Result ``` ### Parameters - **location** (u16) - The flash memory index of the template to delete. ### Returns - `OK`: Template deleted successfully. - Other error codes indicate a failure during the deletion process. ``` -------------------------------- ### Delete Specific Fingerprint Template Source: https://context7.com/mushonnip/fingerprint-sensor/llms.txt Removes a single fingerprint template from a specified flash memory location index. Useful for revoking access. ```rust use fingerprint_sensor::{DeviceBuilder, OK}; fn main() -> std::io::Result<()> { let mut device = DeviceBuilder::new(vec![0xFF; 4], vec![0; 4]) .uart_from_port("/dev/ttyUSB0", 57600)? .build()?; let location: u16 = 5; match device.delete_model(location)? { OK => println!("Template at location {} deleted", location), other => eprintln!("Delete failed, status: {:#X}", other), } Ok(()) } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.