Enum shakmaty::uci::Uci [−][src]
pub enum Uci { Normal { from: Square, to: Square, promotion: Option<Role>, }, Put { role: Role, to: Square, }, Null, }
A move as represented in the UCI protocol.
Variants
Normal
A normal move, e.g. e2e4
or h2h1q
.
Fields of Normal
from: Square | |
to: Square | |
promotion: Option<Role> |
Put
A piece drop, e.g. Q@f7
.
Fields of Put
role: Role | |
to: Square |
Null
A null move (0000
).
Methods
impl Uci
[src]
impl Uci
pub fn from_ascii(uci: &[u8]) -> Result<Uci, InvalidUci>
[src]
pub fn from_ascii(uci: &[u8]) -> Result<Uci, InvalidUci>
Parses a move in UCI notation.
Errors
Returns InvalidUci
if uci
is not syntactically valid.
Examples
use shakmaty::uci::Uci; use shakmaty::Square; let uci = Uci::from_ascii(b"e4e5")?; assert_eq!(uci, Uci::Normal { from: Square::E4, to: Square::E5, promotion: None, });
pub fn from_move<P: Position>(pos: &P, m: &Move) -> Uci
[src]
pub fn from_move<P: Position>(pos: &P, m: &Move) -> Uci
Converts a move to UCI notation.
If pos
does not and did not have castling rights that are only
possible in Chess960,
castling moves are represented as e1g1
, e1c1
, e8g8
and e8c8
.
Alternatively, see
Uci::from_chess960()
.
pub fn from_chess960(m: &Move) -> Uci
[src]
pub fn from_chess960(m: &Move) -> Uci
Converts a move to UCI notation. Castling moves are represented as a move of the king to the corresponding rook square, independently of the position.
pub fn to_move<P: Position>(&self, pos: &P) -> Result<Move, IllegalMove>
[src]
pub fn to_move<P: Position>(&self, pos: &P) -> Result<Move, IllegalMove>
Tries to convert the Uci
to a legal Move
in the context of a
position.
Errors
Returns IllegalMove
if the move is not legal.
Trait Implementations
impl Clone for Uci
[src]
impl Clone for Uci
fn clone(&self) -> Uci
[src]
fn clone(&self) -> Uci
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 Eq for Uci
[src]
impl Eq for Uci
impl PartialEq for Uci
[src]
impl PartialEq for Uci
fn eq(&self, other: &Uci) -> bool
[src]
fn eq(&self, other: &Uci) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Uci) -> bool
[src]
fn ne(&self, other: &Uci) -> bool
This method tests for !=
.
impl Debug for Uci
[src]
impl Debug for Uci
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl FromStr for Uci
[src]
impl FromStr for Uci
type Err = InvalidUci
The associated error which can be returned from parsing.
fn from_str(uci: &str) -> Result<Uci, InvalidUci>
[src]
fn from_str(uci: &str) -> Result<Uci, InvalidUci>
Parses a string s
to return a value of this type. Read more
impl Display for Uci
[src]
impl Display for Uci