1#![forbid(unsafe_code)]
2#![deny(future_incompatible, rust_2018_idioms)]
6
7use std::error::Error;
10use std::fmt::Display;
11
12pub mod reader;
19
20pub mod packet;
21
22mod helpers {
23 pub mod tracked_payload;
24}
25
26#[derive(Debug, thiserror::Error)]
27pub enum ErrorKind {
28 #[error("Invalid first byte for transport stream packet `{byte}`")]
31 InvalidFirstByte {
32 byte: u8,
34 },
35
36 #[error(
39 "Invalid payload pointer `{pointer}` for payload with `{remainder}` bytes remaining"
40 )]
41 InvalidPayloadPointer { pointer: u8, remainder: u8 },
42
43 #[error("Cannot read payload from packet that has none")]
46 NoPayload,
47
48 #[error("Stream contains no SYNC byte")]
51 NoSyncByteFound,
52
53 #[error("Continuation payload cannot be used as a starting payload")]
56 PayloadIsNotStart,
57
58 #[error(transparent)]
59 Unknown(#[from] std::io::Error),
60}
61
62#[derive(Clone, Copy, Debug, PartialEq)]
63pub enum TransportScramblingControl {
64 NoScrambling = 0,
65 Reserved = 1,
66 EvenKey = 2,
67 OddKey = 3,
68}
69#[derive(Clone, Copy, Debug, PartialEq)]
70pub enum AdaptationFieldControl {
71 Reserved = 0,
72 Payload = 1,
73 AdaptationField = 2,
74 AdaptationAndPayload = 3,
75}
76
77#[derive(Clone, Copy, Debug, PartialEq)]
78pub enum Errors {
79 InvalidFirstByte(u8),
80}
81
82impl Error for Errors {}
83
84impl Display for Errors {
85 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
86 match self {
87 Errors::InvalidFirstByte(invalid_byte) => {
88 write!(f, "invalid first byte for packet: [{}]", invalid_byte)
89 }
90 }
91 }
92}