apdu_app/lib.rs
1#![no_std]
2
3pub use iso7816::{command::CommandView, Data, Interface, Status};
4
5pub type Result = iso7816::Result<()>;
6
7/// An App can receive and respond APDUs at behest of the ApduDispatch.
8pub trait App<const R: usize>: iso7816::App {
9 /// Given parsed APDU for select command.
10 /// Write response data back to buf, and return length of payload. Return APDU Error code on error.
11 /// Alternatively, the app can defer the response until later by returning it in `poll()`.
12 fn select(
13 &mut self,
14 interface: Interface,
15 apdu: CommandView<'_>,
16 reply: &mut Data<R>,
17 ) -> Result;
18
19 /// Deselects the app. This is the result of another app getting selected.
20 /// App should clear any sensitive state and reset security indicators.
21 fn deselect(&mut self);
22
23 /// Given parsed APDU for app when selected.
24 /// Write response data back to buf, and return length of payload. Return APDU Error code on error.
25 fn call(&mut self, interface: Interface, apdu: CommandView<'_>, reply: &mut Data<R>) -> Result;
26}