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, Host Control, the full MMI set — low-level/display/keypad/subtitle/
6//! download and high-level menu/list/enq — and Low-Speed Communications), the
7//! session-layer SPDUs and transport-layer TPDUs, plus a `CA_PMT` builder that
8//! turns a `dvb-si` PMT into the object handed to a CICAM.
9//!
10//! Every wire structure implements [`broadcast_common::Parse`] / [`broadcast_common::Serialize`]
11//! symmetrically (parse → serialize is byte-identical), with all length fields
12//! computed from content. Spec citations live in each module doc; the
13//! render-verified transcription is in `docs/en_50221/`.
14//!
15//! Scope: the wire/protocol layer only. The physical PC-Card transport and CI+
16//! crypto (the CC resource) are out of scope. `#![no_std]` (+ `alloc`).
17//!
18//! # Layers
19//!
20//! - [`tag`] / [`length`] — the 3-byte `apdu_tag` and the ASN.1-style
21//! `length_field` shared by all PDUs.
22//! - [`resource`] — the 4-octet `resource_identifier()`.
23//! - [`objects`] — application-layer APDU objects, dispatched by [`AnyApdu`].
24//! - [`spdu`] — session-layer SPDUs (open/create/close session, session number).
25//! - [`tpdu`] — transport-layer framing (C_TPDU/R_TPDU + connection mgmt).
26//! - [`builder`] — the `CA_PMT` projection from a `dvb-si` PMT.
27//!
28//! All Table 58 `apdu_tag`s are now typed; an unallocated/private tag is produced
29//! by [`AnyApdu::parse`] as [`AnyApdu::Unknown`] (lossless round-trip). The CI+
30//! crypto (CC resource) and the PC-Card hardware transport remain out of scope.
31#![no_std]
32#![cfg_attr(docsrs, feature(doc_cfg))]
33#![warn(missing_docs)]
34// Runnable examples, embedded so they render on docs.rs and stay in sync with
35// the actual `examples/*.rs` files (shown, not compiled).
36#![doc = "\n# Examples\n"]
37#![doc = "Two runnable examples ship with this crate (`cargo run -p dvb-ci --example <name>`).\n"]
38#![doc = "\n## `build_ca_pmt`\n\n```rust,ignore"]
39#![doc = include_str!("../examples/build_ca_pmt.rs")]
40#![doc = "```\n\n## `parse_apdu`\n\n```rust,ignore"]
41#![doc = include_str!("../examples/parse_apdu.rs")]
42#![doc = "```"]
43
44extern crate alloc;
45
46pub mod any;
47pub mod builder;
48pub mod ci_ext;
49pub mod ci_plus;
50pub mod error;
51pub mod length;
52pub mod objects;
53pub mod resource;
54pub mod spdu;
55pub mod tag;
56pub mod tpdu;
57pub mod traits;
58
59pub use any::AnyApdu;
60pub use error::{Error, Result};
61pub use resource::ResourceId;
62pub use tag::ApduTag;
63pub use traits::ApduDef;