dvb_ci/lib.rs
1//! DVB Common Interface (EN 50221) — the host↔CICAM wire protocol.
2//!
3//! Parses + builds the EN 50221 protocol objects: resource APDUs (Resource
4//! Manager, Application Information, CA support incl. `ca_pmt`/`ca_pmt_reply`,
5//! Date-Time, MMI close), the session-layer SPDUs and transport-layer TPDUs,
6//! plus a `CA_PMT` builder that turns a `dvb-si` PMT into the object handed to a
7//! CICAM.
8//!
9//! Every wire structure implements [`dvb_common::Parse`] / [`dvb_common::Serialize`]
10//! symmetrically (parse → serialize is byte-identical), with all length fields
11//! computed from content. Spec citations live in each module doc; the
12//! render-verified transcription is in `docs/en_50221/`.
13//!
14//! Scope: the wire/protocol layer only. The physical PC-Card transport and CI+
15//! crypto (the CC resource) are out of scope. `#![no_std]` (+ `alloc`).
16//!
17//! # Layers
18//!
19//! - [`tag`] / [`length`] — the 3-byte `apdu_tag` and the ASN.1-style
20//! `length_field` shared by all PDUs.
21//! - [`resource`] — the 4-octet `resource_identifier()`.
22//! - [`objects`] — application-layer APDU objects, dispatched by [`AnyApdu`].
23//! - [`spdu`] — session-layer SPDUs (open/create/close session, session number).
24//! - [`tpdu`] — transport-layer framing (C_TPDU/R_TPDU + connection mgmt).
25//! - [`builder`] — the `CA_PMT` projection from a `dvb-si` PMT.
26//!
27//! # Deferred to a follow-up
28//!
29//! The MMI **high-level** objects (text/enq/answ/menu/list, Tables 46-51), the
30//! MMI low-level/display objects, the **Host Control** (tune/replace) and
31//! **Low-Speed Communications** resources are not yet typed. Their `apdu_tag`s
32//! are listed in `docs/en_50221/apdu-tag-values.md`; until implemented they are
33//! produced by [`AnyApdu::parse`] as [`AnyApdu::Unknown`] (lossless round-trip).
34#![no_std]
35#![cfg_attr(docsrs, feature(doc_cfg))]
36#![warn(missing_docs)]
37// Runnable examples, embedded so they render on docs.rs and stay in sync with
38// the actual `examples/*.rs` files (shown, not compiled).
39#![doc = "\n# Examples\n"]
40#![doc = "Two runnable examples ship with this crate (`cargo run -p dvb-ci --example <name>`).\n"]
41#![doc = "\n## `build_ca_pmt`\n\n```rust,ignore"]
42#![doc = include_str!("../examples/build_ca_pmt.rs")]
43#![doc = "```\n\n## `parse_apdu`\n\n```rust,ignore"]
44#![doc = include_str!("../examples/parse_apdu.rs")]
45#![doc = "```"]
46
47extern crate alloc;
48
49pub mod any;
50pub mod builder;
51pub mod error;
52pub mod length;
53pub mod objects;
54pub mod resource;
55pub mod spdu;
56pub mod tag;
57pub mod tpdu;
58pub mod traits;
59
60pub use any::AnyApdu;
61pub use error::{Error, Result};
62pub use resource::ResourceId;
63pub use tag::ApduTag;
64pub use traits::ApduDef;