TokenProcessor

Trait TokenProcessor 

Source
pub trait TokenProcessor {
    type Output;

    // Required method
    fn process<P: Prompter>(
        &self,
        input: &mut &[&TokenWithRange<'_>],
        prompter: &P,
    ) -> TokenProcessorResult<Self::Output>;

    // Provided methods
    fn then<S>(self, second: S) -> SequentialProcessor<Self, S>
       where Self: Sized,
             S: TokenProcessor + Sized { ... }
    fn map<F, O>(self, f: F) -> Mapped<Self, F>
       where Self: Sized,
             F: Fn(Self::Output) -> O { ... }
}
Expand description

A processor of tokens in the BMS. An implementation takes control only one feature about definitions and placements such as WAVxx definition and its sound object.

Required Associated Types§

Source

type Output

A result data of the process.

Required Methods§

Source

fn process<P: Prompter>( &self, input: &mut &[&TokenWithRange<'_>], prompter: &P, ) -> TokenProcessorResult<Self::Output>

Processes commands by consuming all the stream input. It mutates input

Provided Methods§

Source

fn then<S>(self, second: S) -> SequentialProcessor<Self, S>
where Self: Sized, S: TokenProcessor + Sized,

Creates a processor SequentialProcessor which does self then second.

Source

fn map<F, O>(self, f: F) -> Mapped<Self, F>
where Self: Sized, F: Fn(Self::Output) -> O,

Maps a result of the processor by the mapping function f.

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<T: TokenProcessor + ?Sized> TokenProcessor for Box<T>

Source§

type Output = <T as TokenProcessor>::Output

Source§

fn process<P: Prompter>( &self, input: &mut &[&TokenWithRange<'_>], prompter: &P, ) -> TokenProcessorResult<Self::Output>

Implementors§

Source§

impl<F, S> TokenProcessor for SequentialProcessor<F, S>

Source§

impl<O, TP, F> TokenProcessor for Mapped<TP, F>
where TP: TokenProcessor, F: Fn(TP::Output) -> O,