pub struct CompactTextRenderer<W> { /* private fields */ }Expand description
Compact text renderer producing LLM-optimised output.
Compared to PlainTextRenderer:
- Fields render as
name: value(no bit widths, no descriptors) - Untaken conditional branches and switch cases are suppressed entirely
FieldTablevalues collapse to inline lists or aligned tables- No spec-grammar keywords (
if,for,switch, braces)
Implementations§
Source§impl<W: Write> CompactTextRenderer<W>
impl<W: Write> CompactTextRenderer<W>
pub fn new(writer: W) -> Self
pub fn into_inner(self) -> W
Trait Implementations§
Source§impl<W: Write> SyntaxWrite for CompactTextRenderer<W>
impl<W: Write> SyntaxWrite for CompactTextRenderer<W>
type Error = TextRenderError
Source§fn begin_element(
&mut self,
name: &str,
params: Option<&str>,
) -> Result<(), Self::Error>
fn begin_element( &mut self, name: &str, params: Option<&str>, ) -> Result<(), Self::Error>
Begin a named syntax element (a “syntax table” in MPEG specs). Read more
Source§fn fixed_width_field(
&mut self,
field: &FixedWidthField<'_>,
) -> Result<(), Self::Error>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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 while_iteration(&mut self, index: u64) -> Result<(), Self::Error>
fn while_iteration(&mut self, index: u64) -> Result<(), Self::Error>
Mark a while-loop iteration.
Source§fn do_while_iteration(&mut self, index: u64) -> Result<(), Self::Error>
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>
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>
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>
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 field_table(&mut self, table: &FieldTable<'_>) -> Result<(), Self::Error>
fn field_table(&mut self, table: &FieldTable<'_>) -> Result<(), Self::Error>
Render a table of homogeneous field values from a loop. Read more
Source§fn assignment(
&mut self,
expression: &str,
computed_value: Option<&Value>,
) -> Result<(), Self::Error>
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.Auto Trait Implementations§
impl<W> Freeze for CompactTextRenderer<W>where
W: Freeze,
impl<W> RefUnwindSafe for CompactTextRenderer<W>where
W: RefUnwindSafe,
impl<W> Send for CompactTextRenderer<W>where
W: Send,
impl<W> Sync for CompactTextRenderer<W>where
W: Sync,
impl<W> Unpin for CompactTextRenderer<W>where
W: Unpin,
impl<W> UnsafeUnpin for CompactTextRenderer<W>where
W: UnsafeUnpin,
impl<W> UnwindSafe for CompactTextRenderer<W>where
W: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more