pub struct BufferedReader<R> { /* private fields */ }
Expand description

A buffered PGN reader.

Implementations§

source§

impl<T: AsRef<[u8]>> BufferedReader<Cursor<T>>

source

pub fn new_cursor(inner: T) -> BufferedReader<Cursor<T>>

Create a new reader by wrapping a byte slice in a Cursor.

use pgn_reader::BufferedReader;

let pgn = b"1. e4 e5 *";
let reader = BufferedReader::new_cursor(&pgn[..]);
source§

impl<R: Read> BufferedReader<R>

source

pub fn new(inner: R) -> BufferedReader<R>

Create a new buffered PGN reader.

use std::fs::File;
use pgn_reader::BufferedReader;

let file = File::open("example.pgn")?;
let reader = BufferedReader::new(file);
source

pub fn read_game<V: Visitor>( &mut self, visitor: &mut V ) -> Result<Option<V::Result>>

Read a single game, if any, and returns 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.
source

pub fn skip_game<V: Visitor>(&mut self) -> Result<bool>

Skip a single game, if any.

§Errors
  • I/O error from the underlying reader.
  • Irrecoverable parser errors.
source

pub fn read_all<V: Visitor>(&mut self, visitor: &mut V) -> Result<()>

Read all games.

§Errors
  • I/O error from the underlying reader.
  • Irrecoverable parser errors.
source

pub fn into_iter<V: Visitor>(self, visitor: &mut V) -> IntoIter<'_, V, R>

Create an iterator over all games.

§Errors
  • I/O error from the underlying reader.
  • Irrecoverable parser errors.
source

pub fn into_inner(self) -> Chain<Cursor<Buffer>, R>

Gets the remaining bytes in the buffer and the underlying reader.

source

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.

Trait Implementations§

source§

impl<R: Debug> Debug for BufferedReader<R>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R> Freeze for BufferedReader<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for BufferedReader<R>
where R: RefUnwindSafe,

§

impl<R> Send for BufferedReader<R>
where R: Send,

§

impl<R> Sync for BufferedReader<R>
where R: Sync,

§

impl<R> Unpin for BufferedReader<R>
where R: Unpin,

§

impl<R> UnwindSafe for BufferedReader<R>
where R: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.