pub trait PgnPosition: Sized + Position + PartialEq {
    const REQUIRED_TAGS: &'static [(&'static str, &'static str)];
    const START_POSITION_TAG_NAME: Option<&'static str>;
    const POSSIBLE_GAME_RESULTS: &'static [(&'static str, Option<GameResult>)] = _;
    const POSSIBLE_MOVE_ANNOTATIONS: &'static [&'static str] = _;

    // Required methods
    fn from_fen_with_settings(
        fen: &str,
        settings: &Self::Settings
    ) -> Result<Self, Error>;
    fn to_fen(&self) -> String;
    fn move_from_san(&self, input: &str) -> Result<Self::Move, Error>;
    fn move_to_san(&self, mv: &Self::Move) -> String;
    fn move_from_lan(&self, input: &str) -> Result<Self::Move, Error>;
    fn move_to_lan(&self, mv: &Self::Move) -> String;

    // Provided methods
    fn pgn_game_result(&self) -> Option<&'static str> { ... }
    fn from_fen(fen: &str) -> Result<Self, Error> { ... }
    fn full_move_number(&self) -> Option<u32> { ... }
}
Expand description

Trait for text representations of game positions and moves.

The terminology used in this trait is specific to chess and chess variants, but it can be implemented for any game.

Required Associated Constants§

source

const REQUIRED_TAGS: &'static [(&'static str, &'static str)]

The required tags, and their default values, for pgn files

source

const START_POSITION_TAG_NAME: Option<&'static str>

The name of a special tag that allows non-standard start positions for a game For such games, parsers need to handle this tag to work correctly In standard chess PGN, this would be Some("FEN") Can be None to disable its usage

Provided Associated Constants§

source

const POSSIBLE_GAME_RESULTS: &'static [(&'static str, Option<GameResult>)] = _

Each possible game result in the pgn

source

const POSSIBLE_MOVE_ANNOTATIONS: &'static [&'static str] = _

Each possible move annotation that can appear at the end of a move A move can have multiple annotations. If one annotation is a substring of another, the longer one must be written first

Required Methods§

source

fn from_fen_with_settings( fen: &str, settings: &Self::Settings ) -> Result<Self, Error>

Constructs a position from Forsyth–Edwards Notation with the given settings.

Extensions to this notation exist for all large chess variants

source

fn to_fen(&self) -> String

Returns a string representation of the position in Forsyth–Edwards Notation.

Extensions to this notation exist for all large chess variants.

source

fn move_from_san(&self, input: &str) -> Result<Self::Move, Error>

Construct a game move from Standard Algebraic Notation, specifically the format used in pgn notation.

Extensions to this notation exist for all large chess variants.

source

fn move_to_san(&self, mv: &Self::Move) -> String

Returns a string representation of the move in Standard Algebraic Notation, specifically the format used in pgn notation.

Extensions to this notation exist for all large chess variants.

source

fn move_from_lan(&self, input: &str) -> Result<Self::Move, Error>

Construct a move from an alternative, long algebraic notation.

This is mostly used for chess and chess variations in the uci interface, or for convenient debugging. Implementations may simply wrap this function around move_from_san where appropriate.

source

fn move_to_lan(&self, mv: &Self::Move) -> String

Returns a string representation of the move in an alternative, long algebraic notation.

This is mostly used for chess and chess variations in the uci interface, or for convenient debugging. Implementations may simply wrap this function around move_to_san where appropriate.

Provided Methods§

source

fn pgn_game_result(&self) -> Option<&'static str>

Returns a more detailed game result string, for games that use these. Must correspond with POSSIBLE_GAME_RESULTS

source

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

Constructs a position from Forsyth–Edwards Notation.

Extensions to this notation exist for all large chess variants

source

fn full_move_number(&self) -> Option<u32>

The number of full moves in the position It starts at 1 and is incremented after the second player’s move

Object Safety§

This trait is not object safe.

Implementors§