Skip to main content

Parser

Trait Parser 

pub trait Parser: 'static {
    type Settings: PartialEq + Clone;
    type Output;
    type Iterator<'a>: Iterator<Item = (Range<usize>, Self::Output)>
       where Self: 'a;

    // Required methods
    fn new(settings: &Self::Settings) -> Self;
    fn update(&mut self, new_settings: &Self::Settings);
    fn change_line(&mut self, line: usize);
    fn parse_line(&mut self, line: &str) -> Self::Iterator<'_>;
    fn current_line(&self) -> usize;
}
Available on crate feature advanced only.
Expand description

A type capable of parsing text, producing some Output.

A Parser parses lines in sequence. When a line changes, it must be notified and the lines after the changed one must be fed again to the Parser.

Required Associated Types§

type Settings: PartialEq + Clone

The settings to configure the Parser.

type Output

The output of this Parser.

type Iterator<'a>: Iterator<Item = (Range<usize>, Self::Output)> where Self: 'a

The parse iterator type.

Required Methods§

fn new(settings: &Self::Settings) -> Self

Creates a new Parser from its Self::Settings.

fn update(&mut self, new_settings: &Self::Settings)

Updates the Parser with some new Self::Settings.

fn change_line(&mut self, line: usize)

Notifies the Parser that the line at the given index has changed.

fn parse_line(&mut self, line: &str) -> Self::Iterator<'_>

Parses the given line.

If a line changed prior to this, the first line provided here will be the line that changed.

fn current_line(&self) -> usize

Returns the current line of the Parser.

If change_line has been called, this will normally be the least index that changed.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Parser for Parser

Source§

type Settings = Settings

Source§

type Output = Code

Source§

type Iterator<'a> = Box<dyn Iterator<Item = (Range<usize>, Code)> + 'a>

Source§

fn new(settings: &<Parser as Parser>::Settings) -> Parser

Source§

fn update(&mut self, new_settings: &<Parser as Parser>::Settings)

Source§

fn change_line(&mut self, line: usize)

Source§

fn parse_line(&mut self, line: &str) -> <Parser as Parser>::Iterator<'_>

Source§

fn current_line(&self) -> usize

Implementors§

§

impl Parser for PlainText

§

type Settings = ()

§

type Output = ()

§

type Iterator<'a> = Empty<(Range<usize>, ())>