Skip to main content

CompactTextRenderer

Struct CompactTextRenderer 

Source
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
  • FieldTable values collapse to inline lists or aligned tables
  • No spec-grammar keywords (if, for, switch, braces)

Implementations§

Source§

impl<W: Write> CompactTextRenderer<W>

Source

pub fn new(writer: W) -> Self

Source

pub fn into_inner(self) -> W

Trait Implementations§

Source§

impl<W: Write> SyntaxWrite for CompactTextRenderer<W>

Source§

type Error = TextRenderError

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). Read more
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 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>

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.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.