Skip to main content

VariantBuilder

Trait VariantBuilder 

Source
pub trait VariantBuilder: Sized + Default {
    // Required methods
    fn name() -> &'static str;
    fn new(game: Game) -> Self;
    fn from_fen(fen: &str) -> Result<Self, FenError>;
    fn from_pgn(pgn: &str) -> Result<Self, PGNError>;
    fn load(path: &str) -> Result<Self, PGNError>;
    fn load_all(path: &str) -> Result<Vec<Self>, PGNError>;
}
Expand description

Construction helpers for variant types.

Required Methods§

Source

fn name() -> &'static str

The name of the variant.

§Returns

The name of the variant.

Source

fn new(game: Game) -> Self

Creates a new instance of the variant.

§Returns

A new instance of the variant.

Source

fn from_fen(fen: &str) -> Result<Self, FenError>

Creates a new instance of the variant from a FEN string.

§Arguments
  • fen - A FEN string.
§Returns

A Result<Self, FenError> object

  • Ok(Self) - A new instance of the variant.
  • Err(FenError) - An error occurred while parsing the FEN string.
Source

fn from_pgn(pgn: &str) -> Result<Self, PGNError>

Creates a new instance of the variant from a PGN string.

§Arguments
  • pgn - A PGN string.
§Returns

A Result<Self, PgnError> object

  • Ok(Self) - A new instance of the variant.
  • Err(PgnError) - An error occurred while parsing the PGN string.
Source

fn load(path: &str) -> Result<Self, PGNError>

Loads the game from a file.

§Arguments
  • path - The path to the file.
§Returns

A Result<Self, PgnError> object

  • Ok(Self) - The game was loaded successfully.
  • Err(PgnError) - An error occurred while loading the game.
Source

fn load_all(path: &str) -> Result<Vec<Self>, PGNError>

Loads multiple games from a file.

§Arguments
  • path - The path to the file.
§Returns

A Result<Vec<Self>, PgnError> object

  • Ok(Vec<Self>) - The games were loaded successfully.
  • Err(PgnError) - An error occurred while loading the games.

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.

Implementors§