ts_analyzer/
lib.rs

1#![forbid(unsafe_code)]
2// Use these checks when closer to complete. They're a bit too strict for early development.
3// #![deny(future_incompatible, missing_docs, rust_2018_idioms, unused, warnings)]
4#![deny(future_incompatible, missing_docs, rust_2018_idioms)]
5
6//! This crate is used to read the payload data from a given transport stream.
7
8use std::{error::Error, fmt::Display};
9
10// Include the README in the doc-tests.
11#[doc = include_str!("../README.md")]
12
13pub mod reader;
14
15pub mod packet;
16
17mod errors {
18    pub mod invalid_first_byte;
19    pub mod no_sync_byte_found;
20    pub mod no_payload;
21    pub mod payload_is_not_start;
22    pub mod invalid_payload_pointer;
23}
24
25mod helpers {
26    pub mod tracked_payload;
27}
28
29#[derive(Clone, Copy, Debug, PartialEq)]
30enum TransportScramblingControl {
31    NoScrambling = 0,
32    Reserved = 1,
33    EvenKey = 2,
34    OddKey = 3,
35}
36#[derive(Clone, Copy, Debug, PartialEq)]
37enum AdaptationFieldControl {
38    Reserved = 0,
39    Payload = 1,
40    AdaptationField = 2,
41    AdaptationAndPayload = 3,
42}
43
44#[derive(Clone, Copy, Debug, PartialEq)]
45enum Errors {
46    InvalidFirstByte(u8),
47
48}
49
50impl Error for Errors {}
51
52impl Display for Errors {
53    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
54        match self {
55            Errors::InvalidFirstByte(invalid_byte) => 
56                write!(f, "invalid first byte for packet: [{}]", invalid_byte),
57        }
58    }
59}