Skip to main content

SyntaxWrite

Trait SyntaxWrite 

Source
pub trait SyntaxWrite {
    type Error: Error;

Show 27 methods // Required methods fn begin_element( &mut self, name: &str, params: Option<&str>, ) -> Result<(), Self::Error>; fn end_element(&mut self) -> Result<(), Self::Error>; fn fixed_width_field( &mut self, field: &FixedWidthField<'_>, ) -> Result<(), Self::Error>; fn variable_length_field( &mut self, field: &VariableLengthField<'_>, ) -> Result<(), Self::Error>; fn bit_pattern( &mut self, field: &BitPatternField<'_>, ) -> Result<(), Self::Error>; fn raw_bytes(&mut self, data: &[u8]) -> Result<(), Self::Error>; fn begin_if( &mut self, condition: &str, terms: &[TermAnnotation<'_>], taken: bool, ) -> Result<(), Self::Error>; fn begin_else_if( &mut self, condition: &str, terms: &[TermAnnotation<'_>], taken: bool, ) -> Result<(), Self::Error>; fn begin_else(&mut self, taken: bool) -> Result<(), Self::Error>; fn end_if(&mut self) -> Result<(), Self::Error>; fn begin_for( &mut self, header: &str, terms: &[TermAnnotation<'_>], ) -> Result<(), Self::Error>; fn for_iteration( &mut self, variable: &str, index: u64, ) -> Result<(), Self::Error>; fn end_for(&mut self) -> Result<(), Self::Error>; fn begin_while(&mut self, condition: &str) -> Result<(), Self::Error>; fn while_iteration(&mut self, index: u64) -> Result<(), Self::Error>; fn end_while(&mut self) -> Result<(), Self::Error>; fn begin_do_while(&mut self) -> Result<(), Self::Error>; fn do_while_iteration(&mut self, index: u64) -> Result<(), Self::Error>; fn end_do_while(&mut self, condition: &str) -> Result<(), Self::Error>; fn begin_switch( &mut self, expression: &str, terms: &[TermAnnotation<'_>], ) -> Result<(), Self::Error>; fn begin_case( &mut self, label: &str, taken: bool, ) -> Result<(), Self::Error>; fn end_case(&mut self) -> Result<(), Self::Error>; fn end_switch(&mut self) -> Result<(), Self::Error>; fn assignment( &mut self, expression: &str, computed_value: Option<&Value>, ) -> Result<(), Self::Error>; fn comment(&mut self, text: &str) -> Result<(), Self::Error>; fn ellipsis(&mut self) -> Result<(), Self::Error>; // Provided method fn field_table(&mut self, table: &FieldTable<'_>) -> Result<(), Self::Error> { ... }
}
Expand description

Trait for rendering MPEG specification syntax structures.

Renderers implement this trait to produce output in a specific format (plain text, ANSI-colored text, HTML, etc.). Producers call these methods to describe the syntax structure and field values.

Methods use begin_/end_ pairs rather than closures to avoid borrow-checker issues when the producer needs &mut W inside a closure while also borrowing &self for data access.

Required Associated Types§

Required Methods§

Source

fn begin_element( &mut self, name: &str, params: Option<&str>, ) -> Result<(), Self::Error>

Begin a named syntax element (a “syntax table” in MPEG specs).

params is None for unparameterized elements like transport_packet(), or Some("payloadType, payloadSize") for parameterized ones like sei_payload(payloadType, payloadSize).

Source

fn end_element(&mut self) -> Result<(), Self::Error>

End the current syntax element.

Source

fn fixed_width_field( &mut self, field: &FixedWidthField<'_>, ) -> Result<(), Self::Error>

Render a fixed-width field.

Source

fn variable_length_field( &mut self, field: &VariableLengthField<'_>, ) -> Result<(), Self::Error>

Render a variable-length coded field.

Source

fn bit_pattern( &mut self, field: &BitPatternField<'_>, ) -> Result<(), Self::Error>

Render a fixed bit pattern or marker bit.

Source

fn raw_bytes(&mut self, data: &[u8]) -> Result<(), Self::Error>

Render raw bytes as a hex dump. Called after a field template line; the renderer formats as hex lines (16 bytes per line).

Source

fn begin_if( &mut self, condition: &str, terms: &[TermAnnotation<'_>], taken: bool, ) -> Result<(), Self::Error>

Begin an if block. The renderer adds if (condition) { and any term annotations. taken is a hint for dimming not-taken branches.

Source

fn begin_else_if( &mut self, condition: &str, terms: &[TermAnnotation<'_>], taken: bool, ) -> Result<(), Self::Error>

Close the previous branch and open an else if branch.

Source

fn begin_else(&mut self, taken: bool) -> Result<(), Self::Error>

Close the previous branch and open an else branch.

Source

fn end_if(&mut self) -> Result<(), Self::Error>

Close the final branch of an if/else-if/else chain.

Source

fn begin_for( &mut self, header: &str, terms: &[TermAnnotation<'_>], ) -> Result<(), Self::Error>

Begin a for loop. header is the loop clause, e.g. "i = 0; i < N; i++". The renderer adds for (header) {.

Source

fn for_iteration( &mut self, variable: &str, index: u64, ) -> Result<(), Self::Error>

Mark a for-loop iteration with the variable name and index.

Source

fn end_for(&mut self) -> Result<(), Self::Error>

End a for loop.

Source

fn begin_while(&mut self, condition: &str) -> Result<(), Self::Error>

Begin a while loop.

Source

fn while_iteration(&mut self, index: u64) -> Result<(), Self::Error>

Mark a while-loop iteration.

Source

fn end_while(&mut self) -> Result<(), Self::Error>

End a while loop.

Source

fn begin_do_while(&mut self) -> Result<(), Self::Error>

Begin a do-while loop.

Source

fn do_while_iteration(&mut self, index: u64) -> Result<(), Self::Error>

Mark a do-while iteration.

Source

fn end_do_while(&mut self, condition: &str) -> Result<(), Self::Error>

End a do-while loop with the given condition.

Source

fn begin_switch( &mut self, expression: &str, terms: &[TermAnnotation<'_>], ) -> Result<(), Self::Error>

Begin a switch statement. expression is the switch discriminator, e.g. "id". terms provides term annotations for the discriminator.

Source

fn begin_case(&mut self, label: &str, taken: bool) -> Result<(), Self::Error>

Begin a case within a switch. label is the case label, e.g. "ID_CPE". taken indicates whether this is the active case.

Source

fn end_case(&mut self) -> Result<(), Self::Error>

End the current case.

Source

fn end_switch(&mut self) -> Result<(), Self::Error>

End the switch statement.

Source

fn assignment( &mut self, expression: &str, computed_value: Option<&Value>, ) -> Result<(), Self::Error>

Render an inline variable assignment. computed_value of Some(value) renders a trailing /* = value */ annotation.

Source

fn comment(&mut self, text: &str) -> Result<(), Self::Error>

Render a standalone comment line.

Source

fn ellipsis(&mut self) -> Result<(), Self::Error>

Render an ellipsis (...) indicating omitted content.

Provided Methods§

Source

fn field_table(&mut self, table: &FieldTable<'_>) -> Result<(), Self::Error>

Render a table of homogeneous field values from a loop.

The default implementation expands the table into a for loop with one iteration per row. Compact renderers override this to produce inline lists or aligned tables.

Implementors§