pub struct Reader<R> { /* private fields */ }Expand description
Implementations§
Source§impl<R: Read> Reader<R>
impl<R: Read> Reader<R>
Sourcepub fn new(reader: R) -> Reader<R>
pub fn new(reader: R) -> Reader<R>
Create a reader with default settings based on the PGN standard.
Sourcepub fn build(reader: R) -> ReaderBuilder<R>
pub fn build(reader: R) -> ReaderBuilder<R>
Build a reader with custom settings.
use std::fs::File;
use pgn_reader::Reader;
let reader = Reader::build(File::open("example.pgn")?)
.set_supported_tag_line_length(1000)
.set_supported_comment_length(4000)
.finish();Sourcepub fn read_game<V: Visitor>(
&mut self,
visitor: &mut V,
) -> Result<Option<V::Output>>
pub fn read_game<V: Visitor>( &mut self, visitor: &mut V, ) -> Result<Option<V::Output>>
Read a single game, if any, and return the result produced by the visitor.
Returns Ok(None) if the underlying reader is empty.
§Errors
- I/O error from the underlying reader.
- Irrecoverable parser errors.
Sourcepub fn has_more(&mut self) -> Result<bool>
pub fn has_more(&mut self) -> Result<bool>
Returns whether the reader has another game to parse, but does not actually parse it.
§Errors
- I/O error from the underlying reader.
- Irrecoverable parser errors (while trying to read previous unfinished game to completion).
Sourcepub fn skip_game(&mut self) -> Result<bool>
pub fn skip_game(&mut self) -> Result<bool>
Skip a single game, if any.
Returns Ok(true) if a game found and skipped.
§Errors
- I/O error from the underlying reader.
- Irrecoverable parser errors.
Sourcepub fn read_games<'a, V: Visitor>(
&'a mut self,
visitor: &'a mut V,
) -> ReadGames<'a, R, V> ⓘ
pub fn read_games<'a, V: Visitor>( &'a mut self, visitor: &'a mut V, ) -> ReadGames<'a, R, V> ⓘ
Iterate over all games, yielding the visitor outputs.
Sourcepub fn visit_all_games<V: Visitor>(&mut self, visitor: &mut V) -> Result<()>
pub fn visit_all_games<V: Visitor>(&mut self, visitor: &mut V) -> Result<()>
Visit all games, ignoring the visitor outputs.
§Errors
- I/O error from the underlying reader.
- Irrecoverable parser errors.
Sourcepub fn into_inner(self) -> R
pub fn into_inner(self) -> R
Discard the remaining bytes in the buffer (Reader::buffer()) and
get the underlying reader.
Trait Implementations§
Source§impl<R: Seek> Seek for Reader<R>
impl<R: Seek> Seek for Reader<R>
Source§fn seek(&mut self, pos: SeekFrom) -> Result<u64>
fn seek(&mut self, pos: SeekFrom) -> Result<u64>
Seek to an offset, in bytes, in a stream. Read more
Source§fn seek_relative(&mut self, offset: i64) -> Result<()>
fn seek_relative(&mut self, offset: i64) -> Result<()>
Seeks relative to the current position. Read more
Source§fn stream_position(&mut self) -> Result<u64>
fn stream_position(&mut self) -> Result<u64>
Returns the current seek position from the start of the stream. Read more
Auto Trait Implementations§
impl<R> Freeze for Reader<R>where
R: Freeze,
impl<R> RefUnwindSafe for Reader<R>where
R: RefUnwindSafe,
impl<R> Send for Reader<R>where
R: Send,
impl<R> Sync for Reader<R>where
R: Sync,
impl<R> Unpin for Reader<R>where
R: Unpin,
impl<R> UnwindSafe for Reader<R>where
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more