Skip to main content

LineStream

Trait LineStream 

Source
pub trait LineStream<'a> {
    // Required methods
    fn next_line(&mut self) -> Option<&'a str>;
    fn peek_line(&mut self) -> Option<&'a str>;

    // Provided methods
    fn remainder_is_whitespace(&mut self) -> bool { ... }
    fn blank_line_opens_section(&mut self) -> bool { ... }
    fn blank_opens_velocity_block(&mut self) -> bool { ... }
    fn next_coord_row(
        &mut self,
        spec_version: u32,
        default_id: u64,
    ) -> Result<([f64; 3], [bool; 3], u64), ParseError> { ... }
}
Expand description

Line source with peek for section detection (blank-line separators).

Implemented by the memchr cursor on the hot iterator path and by Peekable<I> for tests / ad-hoc callers.

Required Methods§

Source

fn next_line(&mut self) -> Option<&'a str>

Source

fn peek_line(&mut self) -> Option<&'a str>

Provided Methods§

Source

fn remainder_is_whitespace(&mut self) -> bool

True when every remaining line, including the current peek, is empty or whitespace. Default is false so a one-line peek cannot hide a following section.

Source

fn blank_line_opens_section(&mut self) -> bool

Called while a blank line is peeked. True when that blank begins a section: the next line is a symbol and the line after it is a component label. A blank that does not is line 1 of the next frame.

Source

fn blank_opens_velocity_block(&mut self) -> bool

With a blank line peeked, true when Self::blank_line_opens_section is true. A stream that cannot look ahead keeps the legacy rule and returns true.

Source

fn next_coord_row( &mut self, spec_version: u32, default_id: u64, ) -> Result<([f64; 3], [bool; 3], u64), ParseError>

One coordinate row, fused with the line scan when the stream can do it.

The default pulls a &str line. crate::iterators::MemchrLines parses the row directly from the byte cursor so tokenize and numeric parse are one pass.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<'a, I> LineStream<'a> for Peekable<I>
where I: Iterator<Item = &'a str> + Clone,

Source§

fn next_line(&mut self) -> Option<&'a str>

Source§

fn peek_line(&mut self) -> Option<&'a str>

Source§

fn blank_line_opens_section(&mut self) -> bool

Source§

fn blank_opens_velocity_block(&mut self) -> bool

Implementors§

Source§

impl<'a> LineStream<'a> for MemchrLines<'a>