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