pub use carrier_core::envelope::{SignaturId, Zeitstempel};
use super::{Anfrage, Meldung, Teq};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Release {
pub major: u8,
pub minor: u8,
}
impl Release {
pub const WBCI_2_0: Self = Self { major: 2, minor: 0 };
}
impl Default for Release {
fn default() -> Self {
Self::WBCI_2_0
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Control {
pub zeitstempel: Zeitstempel,
pub release: Release,
pub signatur: SignaturId,
}
impl Control {
#[must_use]
pub fn new(zeitstempel: impl Into<Zeitstempel>, signatur: SignaturId) -> Self {
Self { zeitstempel: zeitstempel.into(), release: Release::WBCI_2_0, signatur }
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[allow(clippy::large_enum_variant)]
pub enum Payload {
AnfrageRequest {
control: Control,
anfrage: Anfrage,
},
AnfrageResponse {
control: Control,
quittung: Teq,
},
MeldungRequest {
control: Control,
meldung: Meldung,
},
MeldungResponse {
control: Control,
quittung: Teq,
},
}
impl Payload {
#[must_use]
pub const fn control(&self) -> &Control {
match self {
Self::AnfrageRequest { control, .. }
| Self::AnfrageResponse { control, .. }
| Self::MeldungRequest { control, .. }
| Self::MeldungResponse { control, .. } => control,
}
}
}