ledger_proto/
error.rs

1//! Apdu error information for encoding / decoding etc.
2
3/// APDU error type
4#[derive(Debug, displaydoc::Display)]
5#[cfg_attr(feature = "std", derive(thiserror::Error))]
6pub enum ApduError {
7    /// Invalid buffer length
8    InvalidLength,
9
10    /// Invalid Utf8 string encoding
11    InvalidUtf8,
12
13    /// Invalid APDU encoding version {0}
14    InvalidVersion(u8),
15
16    /// Invalid APDU encoding
17    InvalidEncoding,
18}
19
20impl From<encdec::Error> for ApduError {
21    fn from(value: encdec::Error) -> Self {
22        match value {
23            encdec::Error::Length => Self::InvalidLength,
24            encdec::Error::Utf8 => Self::InvalidUtf8,
25        }
26    }
27}