wasefire_board_api/fingerprint.rs
1// Copyright 2025 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Fingerprint interface.
16
17#[cfg(feature = "api-fingerprint-matcher")]
18pub mod matcher;
19#[cfg(feature = "api-fingerprint-sensor")]
20pub mod sensor;
21
22/// Fingerprint event.
23#[cfg_attr(feature = "defmt", derive(defmt::Format))]
24#[derive(Debug, PartialEq, Eq)]
25pub enum Event {
26 /// Fingerprint matcher event.
27 #[cfg(feature = "api-fingerprint-matcher")]
28 Matcher(matcher::Event),
29
30 /// Fingerprint sensor event.
31 #[cfg(feature = "api-fingerprint-sensor")]
32 Sensor(sensor::Event),
33}
34
35impl<B: crate::Api> From<Event> for crate::Event<B> {
36 fn from(event: Event) -> Self {
37 crate::Event::Fingerprint(event)
38 }
39}
40
41/// Fingerprint interface.
42pub trait Api: Send {
43 /// Fingerprint matcher interface.
44 #[cfg(feature = "api-fingerprint-matcher")]
45 type Matcher: matcher::Api;
46
47 /// Fingerprint sensor interface.
48 #[cfg(feature = "api-fingerprint-sensor")]
49 type Sensor: sensor::Api;
50}
51
52/// Fingerprint matcher interface.
53#[cfg(feature = "api-fingerprint-matcher")]
54pub type Matcher<B> = <super::Fingerprint<B> as Api>::Matcher;
55
56/// Fingerprint sensor interface.
57#[cfg(feature = "api-fingerprint-sensor")]
58pub type Sensor<B> = <super::Fingerprint<B> as Api>::Sensor;