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
Visits games from a Reader.
Visitor methods are called in these phases:
Required Associated Types§
Sourcetype Tags
type Tags
Produced by Visitor::begin_tags().
Sourcetype Movetext
type Movetext
Produced by Visitor::begin_movetext().
Sourcetype Output
type Output
Produced by Visitor::end_game() or a short-circuiting
ControlFlow::Break(_) returned from any of the other methods.
Required Methods§
Called at the start of the game, directly before reading game tags.
Sourcefn begin_movetext(
&mut self,
tags: Self::Tags,
) -> ControlFlow<Self::Output, Self::Movetext>
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.
Provided Methods§
Sourcefn tag(
&mut self,
tags: &mut Self::Tags,
name: &[u8],
value: RawTag<'_>,
) -> ControlFlow<Self::Output>
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"].
Sourcefn san(
&mut self,
movetext: &mut Self::Movetext,
san_plus: SanPlus,
) -> ControlFlow<Self::Output>
fn san( &mut self, movetext: &mut Self::Movetext, san_plus: SanPlus, ) -> ControlFlow<Self::Output>
Called for each move, like Nf3+.
Sourcefn nag(
&mut self,
movetext: &mut Self::Movetext,
nag: Nag,
) -> ControlFlow<Self::Output>
fn nag( &mut self, movetext: &mut Self::Movetext, nag: Nag, ) -> ControlFlow<Self::Output>
Called for each numeric annotation glyph, like !? or $7.
Sourcefn partial_comment(
&mut self,
movetext: &mut Self::Movetext,
comment: RawComment<'_>,
) -> ControlFlow<Self::Output>
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().
Sourcefn 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>
Called for each { comment }.
Sourcefn begin_variation(
&mut self,
movetext: &mut Self::Movetext,
) -> ControlFlow<Self::Output, Skip>
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.
Sourcefn end_variation(
&mut self,
movetext: &mut Self::Movetext,
) -> ControlFlow<Self::Output>
fn end_variation( &mut self, movetext: &mut Self::Movetext, ) -> ControlFlow<Self::Output>
Called for each ). It is not guaranteed that there was a
matching (.