ogg_core/error.rs
1//! Public error type.
2
3#![forbid(unsafe_code)]
4
5/// Errors from Ogg mux/demux.
6#[derive(Debug, thiserror::Error)]
7#[non_exhaustive]
8pub enum Error {
9 /// First 4 bytes are not `OggS`.
10 #[error("bad Ogg capture pattern (expected \"OggS\")")]
11 BadCapturePattern,
12 /// Page `version` byte is not `0`.
13 #[error("unsupported Ogg page version {0} (only 0 is defined)")]
14 UnsupportedVersion(u8),
15 /// Page CRC-32 doesn't match the computed value over the page bytes.
16 #[error("Ogg page CRC mismatch: header claims {expected:#010x}, computed {computed:#010x}")]
17 CrcMismatch {
18 /// CRC from the page header.
19 expected: u32,
20 /// CRC recomputed over the page bytes.
21 computed: u32,
22 },
23 /// A page's `continued packet` flag doesn't match whether a partial packet is
24 /// actually buffered — a real stream desync, not a value worth guessing past.
25 #[error("Ogg page continuation flag ({flag}) doesn't match buffered partial-packet state")]
26 ContinuationFlagMismatch {
27 /// The page's `continued packet` header bit.
28 flag: bool,
29 },
30 /// `Muxer::push_packet`'s packet doesn't fit in a single page's 255-entry
31 /// segment table (max 65024 bytes) — multi-page packet splitting is a v1
32 /// scope gap (crate-local ADR-0001).
33 #[error(
34 "packet of {0} bytes doesn't fit in a single Ogg page (max 65024 bytes; multi-page splitting not yet implemented)"
35 )]
36 PacketTooLargeForSinglePage(usize),
37}