Visitor

Trait Visitor 

Source
pub trait Visitor {
    type Tags;
    type Movetext;
    type Output;

    // Required methods
    fn begin_tags(&mut self) -> ControlFlow<Self::Output, Self::Tags>;
    fn begin_movetext(
        &mut self,
        tags: Self::Tags,
    ) -> ControlFlow<Self::Output, Self::Movetext>;
    fn end_game(&mut self, movetext: Self::Movetext) -> Self::Output;

    // Provided methods
    fn tag(
        &mut self,
        tags: &mut Self::Tags,
        name: &[u8],
        value: RawTag<'_>,
    ) -> ControlFlow<Self::Output> { ... }
    fn san(
        &mut self,
        movetext: &mut Self::Movetext,
        san_plus: SanPlus,
    ) -> ControlFlow<Self::Output> { ... }
    fn nag(
        &mut self,
        movetext: &mut Self::Movetext,
        nag: Nag,
    ) -> ControlFlow<Self::Output> { ... }
    fn partial_comment(
        &mut self,
        movetext: &mut Self::Movetext,
        comment: RawComment<'_>,
    ) -> ControlFlow<Self::Output> { ... }
    fn comment(
        &mut self,
        movetext: &mut Self::Movetext,
        comment: RawComment<'_>,
    ) -> ControlFlow<Self::Output> { ... }
    fn begin_variation(
        &mut self,
        movetext: &mut Self::Movetext,
    ) -> ControlFlow<Self::Output, Skip> { ... }
    fn end_variation(
        &mut self,
        movetext: &mut Self::Movetext,
    ) -> ControlFlow<Self::Output> { ... }
    fn outcome(
        &mut self,
        movetext: &mut Self::Movetext,
        outcome: Outcome,
    ) -> ControlFlow<Self::Output> { ... }
}
Expand description

Required Associated Types§

Source

type Tags

Produced by Visitor::begin_tags().

Source

type Movetext

Source

type Output

Produced by Visitor::end_game() or a short-circuiting ControlFlow::Break(_) returned from any of the other methods.

Required Methods§

Source

fn begin_tags(&mut self) -> ControlFlow<Self::Output, Self::Tags>

Called at the start of the game, directly before reading game tags.

Source

fn begin_movetext( &mut self, tags: Self::Tags, ) -> ControlFlow<Self::Output, Self::Movetext>

Called after reading the tags of a game, before reading the movetext.

Source

fn end_game(&mut self, movetext: Self::Movetext) -> Self::Output

Called after parsing a game.

Provided Methods§

Source

fn tag( &mut self, tags: &mut Self::Tags, name: &[u8], value: RawTag<'_>, ) -> ControlFlow<Self::Output>

Called when parsing a game tag pair, like [White "Deep Blue"].

Source

fn san( &mut self, movetext: &mut Self::Movetext, san_plus: SanPlus, ) -> ControlFlow<Self::Output>

Called for each move, like Nf3+.

Source

fn nag( &mut self, movetext: &mut Self::Movetext, nag: Nag, ) -> ControlFlow<Self::Output>

Called for each numeric annotation glyph, like !? or $7.

Source

fn partial_comment( &mut self, movetext: &mut Self::Movetext, comment: RawComment<'_>, ) -> ControlFlow<Self::Output>

Called for { comment }s which exceed the size of the reader’s movetext token buffer.

This method will be called once for every buffer-sized chunk of the comment, except for the last one in which the closing } is finally encountered, for which Visitor::comment() will be called instead. This method’s default implementation simply forwards its arguments to comment(), so if you don’t override it, long comments will look like a series of several short ones.

The reader will avoid splitting chunks in the middle of a multibyte UTF-8 sequence, therefore it’s guaranteed that if the comment is valid UTF-8, then so is every chunk.

Buffer size is configurable via ReaderBuilder::set_supported_comment_length().

Source

fn comment( &mut self, movetext: &mut Self::Movetext, comment: RawComment<'_>, ) -> ControlFlow<Self::Output>

Called for each { comment }.

Source

fn begin_variation( &mut self, movetext: &mut Self::Movetext, ) -> ControlFlow<Self::Output, Skip>

Called for each (.

Defaults to skip over the following variation directly to Visitor::end_variation() (or to Visitor::end_game() if no matching ) follows before the end of the game.

Source

fn end_variation( &mut self, movetext: &mut Self::Movetext, ) -> ControlFlow<Self::Output>

Called for each ). It is not guaranteed that there was a matching (.

Source

fn outcome( &mut self, movetext: &mut Self::Movetext, outcome: Outcome, ) -> ControlFlow<Self::Output>

Called for each game termination, like * or 1-0.

Implementors§