ledger_sdk_transport/lib.rs
1use std::ops::Deref;
2
3pub use async_trait::async_trait;
4pub use ledger_sdk_apdu::{APDUAnswer, APDUCommand, APDUErrorCode};
5
6/// Use to talk to the ledger device
7#[async_trait]
8pub trait Exchange {
9 /// Error defined by Transport used
10 type Error;
11
12 /// The concrete type containing the APDUAnswer
13 type AnswerType: Deref<Target = [u8]> + Send;
14
15 /// Send a command with the given transport and retrieve an answer or a transport error
16 async fn exchange<I>(
17 &self,
18 command: &APDUCommand<I>,
19 ) -> Result<APDUAnswer<Self::AnswerType>, Self::Error>
20 where
21 I: Deref<Target = [u8]> + Send + Sync;
22}