pub struct Section<'a> {
pub table_id: u8,
pub section_syntax_indicator: bool,
pub private_indicator: bool,
pub section_length: u16,
pub extension_id: u16,
pub version_number: u8,
pub current_next_indicator: bool,
pub section_number: u8,
pub last_section_number: u8,
pub payload: &'a [u8],
pub crc32: Option<u32>,
}Expand description
A parsed PSI/SI section header, borrowing the raw input buffer for payload.
Created via Section::parse(bytes). Does not validate the CRC on
construction — call Section::validate_crc explicitly.
Fields§
§table_id: u8Table identifier.
section_syntax_indicator: boolWhen true the section uses the long-form syntax (has extension header
and CRC). When false only the 3-byte header is present (short form,
e.g. TDT — but see the module docs for the TOT exception: SSI=0 yet
CRC present; parse TOT via tables::tot, not this path).
private_indicator: boolPrivate indicator bit (meaning is table-specific).
section_length: u16Number of bytes following byte 2 of the section header.
extension_id: u16Table ID extension (aka table_id_extension). Present only for
long-form sections; zero for short-form.
version_number: u8Version number (5 bits). Present only for long-form sections.
current_next_indicator: boolcurrent_next_indicator flag. Present only for long-form sections.
section_number: u8Section number within the table sub-table.
last_section_number: u8Number of the last section in the table sub-table.
payload: &'a [u8]Section payload: excludes the header bytes and the trailing CRC for
long-form sections. For short-form sections this is bytes
3..(section_length + 3).
crc32: Option<u32>Declared CRC value (last 4 bytes, big-endian). None for short-form
sections which carry no CRC.
Implementations§
Source§impl<'a> Section<'a>
impl<'a> Section<'a>
Sourcepub fn payload(&self) -> &'a [u8] ⓘ
pub fn payload(&self) -> &'a [u8] ⓘ
Return the payload slice (same as the payload field — convenience
getter for code that has a &Section reference).
Sourcepub fn validate_crc(&self, raw: &[u8]) -> Result<()>
pub fn validate_crc(&self, raw: &[u8]) -> Result<()>
Validate the CRC-32 of the section against raw — the complete section
bytes (including header and CRC suffix).
For short-form sections (section_syntax_indicator == false) this
returns Ok(()) immediately because no CRC is present.
§Errors
Returns Error::CrcMismatch when the computed CRC over
raw[..raw.len() - 4] does not match the declared value at
raw[raw.len()-4..].
Trait Implementations§
Source§impl<'de: 'a, 'a> Deserialize<'de> for Section<'a>
impl<'de: 'a, 'a> Deserialize<'de> for Section<'a>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl<'a> Eq for Section<'a>
Source§impl<'a> Parse<'a> for Section<'a>
impl<'a> Parse<'a> for Section<'a>
Source§fn parse(bytes: &'a [u8]) -> Result<Self>
fn parse(bytes: &'a [u8]) -> Result<Self>
Parse a complete section from bytes.
§Errors
Error::BufferTooShort— fewer than 3 bytes supplied.Error::SectionLengthOverflow—section_lengthfield declares more data thanbytescontains.
Source§impl<'a> PartialEq for Section<'a>
impl<'a> PartialEq for Section<'a>
Source§impl Serialize for Section<'_>
impl Serialize for Section<'_>
Source§type Error = Error
type Error = Error
Parse impl, but need not be).Source§fn serialized_len(&self) -> usize
fn serialized_len(&self) -> usize
serialize_into will write.