rtmp_runtime/error.rs
1//! Error type for the RTMP ingest session engine.
2//!
3//! Structured [`thiserror`] errors covering the failure surface of the
4//! sans-IO engine: handshake framing (§5.2), chunk stream parsing (§5.3),
5//! message reassembly (§6), AMF0 decoding (`[AMF0]`), and session state-machine
6//! violations (§7.2) — see [`docs/rtmp.md`](../docs/rtmp.md).
7
8/// Errors produced by the RTMP ingest session engine.
9#[non_exhaustive]
10#[derive(Debug, thiserror::Error)]
11pub enum RtmpError {
12 /// Not enough input bytes were available to parse a complete structure
13 /// (handshake message, chunk header, or reassembled RTMP message).
14 #[error("buffer too short for {what}: need {need}, have {have}")]
15 BufferTooShort {
16 /// Number of bytes required to complete the parse.
17 need: usize,
18 /// Number of bytes actually available.
19 have: usize,
20 /// What was being parsed when the buffer ran out.
21 what: &'static str,
22 },
23
24 /// The input did not conform to the expected wire layout (bad handshake
25 /// version, invalid chunk `fmt`/CSID encoding, malformed AMF0 value, or
26 /// similar).
27 #[error("malformed {what}")]
28 Malformed {
29 /// What was being parsed when the malformed data was found.
30 what: &'static str,
31 },
32
33 /// An operation was attempted that is not valid in the session's current
34 /// state (e.g. a command received before the handshake completed, or
35 /// `publish` before `createStream`).
36 #[error("unexpected state: {what}")]
37 UnexpectedState {
38 /// Description of the state violation.
39 what: &'static str,
40 },
41
42 /// The input used a feature or value this engine does not (yet) support
43 /// (e.g. AMF3, an unrecognised command name).
44 #[error("unsupported: {what}")]
45 Unsupported {
46 /// What is unsupported.
47 what: &'static str,
48 },
49}