1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use crate::application_protocol::{
    application_pdu::ApduType, confirmed::ConfirmedServiceChoice,
    services::read_range::ReadRangeValueType, unconfirmed::UnconfirmedServiceChoice,
};

use super::tag::{ApplicationTagNumber, Tag, TagNumber};

#[derive(Debug, Clone)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Error {
    Length((&'static str, u32)),
    InvalidValue(&'static str),
    InvalidVariant((&'static str, u32)),
    Unknown,
    Unimplemented(Unimplemented),
    SegmentationNotSupported,
    UnexpectedInvokeId,
    Io,
    ApduTypeNotSupported(ApduType),
    ExpectedTag(ExpectedTag),
    ExpectedOpeningTag(TagNumber),
    TagNotSupported((&'static str, TagNumber)),
    TagValueInvalid((&'static str, Tag, u32)),
    ReaderEof(usize),
}

#[derive(Debug, Clone)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Unimplemented {
    ConfirmedServiceChoice(ConfirmedServiceChoice),
    UnconfirmedServiceChoice(UnconfirmedServiceChoice),
    ReadRangeValueType(ReadRangeValueType),
    ApplicationTagNumber(ApplicationTagNumber),
}

#[derive(Debug, Clone)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ExpectedTag {
    pub context: &'static str,
    pub expected: TagNumber,
    pub actual: TagNumber,
}