Enum pgn_reader::San [−][src]
pub enum San { Normal { role: Role, file: Option<File>, rank: Option<Rank>, capture: bool, to: Square, promotion: Option<Role>, }, Castle(CastlingSide), Put { role: Role, to: Square, }, Null, }
A move in Standard Algebraic Notation.
Variants
Normal
Fields of Normal
role: Role | |
file: Option<File> | |
rank: Option<Rank> | |
capture: bool | |
to: Square | |
promotion: Option<Role> |
Castle(CastlingSide)
Put
Fields of Put
role: Role | |
to: Square |
Null
Methods
impl San
[src]
impl San
pub fn from_ascii(san: &[u8]) -> Result<San, InvalidSan>
[src]
pub fn from_ascii(san: &[u8]) -> Result<San, InvalidSan>
Parses a SAN. Ignores a possible check or checkmate suffix.
Errors
Returns InvalidSan
if san
is not syntactically valid.
pub fn from_move<P>(pos: &P, m: &Move) -> San where
P: Position,
[src]
pub fn from_move<P>(pos: &P, m: &Move) -> San where
P: Position,
Converts a move to Standard Algebraic Notation.
pub fn to_move<P>(&self, pos: &P) -> Result<Move, SanError> where
P: Position,
[src]
pub fn to_move<P>(&self, pos: &P) -> Result<Move, SanError> where
P: Position,
Tries to convert the San
to a legal move in the context of a
position.
Errors
Returns SanError
if there is no unique matching legal move.
pub fn find_move(
&self,
moves: &'a ArrayVec<[Move; 512]>
) -> Result<&'a Move, SanError>
[src]
pub fn find_move(
&self,
moves: &'a ArrayVec<[Move; 512]>
) -> Result<&'a Move, SanError>
Searches a MoveList
for a unique matching move.
Errors
Returns SanError
if there is no unique matching legal move.
pub fn matches(&self, m: &Move) -> bool
[src]
pub fn matches(&self, m: &Move) -> bool
Test if the San
can match the Move
(in any position).
Examples
use shakmaty::{Square, Role, Move}; use shakmaty::san::San; let m = Move::Normal { role: Role::Knight, from: Square::G1, to: Square::F3, capture: None, promotion: None, }; let nf3 = San::from_ascii(b"Nf3")?; assert!(nf3.matches(&m)); let ng1f3 = San::from_ascii(b"Ng1f3")?; assert!(ng1f3.matches(&m)); // capture does not match let nxf3 = San::from_ascii(b"Nxf3")?; assert!(!nxf3.matches(&m)); // other file does not match let nef3 = San::from_ascii(b"Nef3")?; assert!(!nef3.matches(&m));
Trait Implementations
impl Clone for San
[src]
impl Clone for San
fn clone(&self) -> San
[src]
fn clone(&self) -> San
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl FromStr for San
[src]
impl FromStr for San
type Err = InvalidSan
The associated error which can be returned from parsing.
fn from_str(san: &str) -> Result<San, InvalidSan>
[src]
fn from_str(san: &str) -> Result<San, InvalidSan>
Parses a string s
to return a value of this type. Read more
impl Debug for San
[src]
impl Debug for San
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter. Read more
impl Display for San
[src]
impl Display for San
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter. Read more
impl Eq for San
[src]
impl Eq for San
impl PartialEq<San> for San
[src]
impl PartialEq<San> for San