Skip to main content

dvb_ci/
traits.rs

1//! `dvb-ci`-specific dispatch trait. `Parse` / `Serialize` come from
2//! `broadcast_common` and are imported at the call sites.
3//!
4//! Mirrors dvb-si's `DescriptorDef` and scte35-splice's `CommandDef`: each typed
5//! APDU object declares its 3-byte `apdu_tag` and a SCREAMING_SNAKE diagnostic
6//! `NAME`, and the `declare_apdus!` dispatch macro pins the tag in the dispatch
7//! list to the trait const via a drift test, so the list can never silently
8//! drift from the implemented set.
9//!
10//! The `Parse` impl on each object parses the **whole** APDU including its
11//! `apdu_tag` + `length_field` header, and the `Serialize` impl writes the whole
12//! APDU back — so dispatch can route on the header and round-trip is symmetric.
13
14use crate::tag::ApduTag;
15use broadcast_common::Parse;
16
17/// Implemented by every typed APDU object; drives [`crate::AnyApdu`] dispatch.
18pub trait ApduDef<'a>: Parse<'a, Error = crate::error::Error> {
19    /// The object's 3-byte `apdu_tag` (EN 50221 Table 58).
20    const TAG: ApduTag;
21    /// Diagnostic name, SCREAMING_SNAKE, suffix-free: `CA_PMT`, `PROFILE_ENQ`,
22    /// `APPLICATION_INFO`, `DATE_TIME`.
23    const NAME: &'static str;
24}