bacnet_emb/common/
error.rs

1use crate::{
2    application_protocol::{
3        application_pdu::ApduType, confirmed::ConfirmedServiceChoice,
4        services::read_range::ReadRangeValueType, unconfirmed::UnconfirmedServiceChoice,
5    },
6    common::tag::{ApplicationTagNumber, Tag, TagNumber},
7};
8
9#[derive(Debug, Clone)]
10#[cfg_attr(feature = "defmt", derive(defmt::Format))]
11#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
12pub enum Error {
13    Length((&'static str, u32)),
14    InvalidValue(&'static str),
15    InvalidVariant((&'static str, u32)),
16    Unimplemented(Unimplemented),
17    SegmentationNotSupported,
18    ApduTypeNotSupported(ApduType),
19    ExpectedTag(ExpectedTag),
20    ExpectedOpeningTag(TagNumber),
21    TagNotSupported((&'static str, TagNumber)),
22    TagValueInvalid((&'static str, Tag, u32)),
23    ReaderEof(usize),
24    ConvertDataLink(&'static str),
25}
26
27#[derive(Debug, Clone)]
28#[cfg_attr(feature = "defmt", derive(defmt::Format))]
29#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
30pub enum Unimplemented {
31    ConfirmedServiceChoice(ConfirmedServiceChoice),
32    UnconfirmedServiceChoice(UnconfirmedServiceChoice),
33    ReadRangeValueType(ReadRangeValueType),
34    ApplicationTagNumber(ApplicationTagNumber),
35}
36
37#[derive(Debug, Clone)]
38#[cfg_attr(feature = "defmt", derive(defmt::Format))]
39#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
40pub struct ExpectedTag {
41    pub context: &'static str,
42    pub expected: TagNumber,
43    pub actual: TagNumber,
44}