[][src]Enum shakmaty::uci::Uci

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: Squareto: Squarepromotion: Option<Role>
Put

A piece drop, e.g. Q@f7.

Fields of Put

role: Roleto: Square
Null

A null move (0000).

Implementations

impl Uci[src]

pub fn from_ascii(uci: &[u8]) -> Result<Uci, ParseUciError>[src]

Parses a move in UCI notation.

Errors

Returns ParseUciError 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_standard(m: &Move) -> Uci[src]

Converts a move to UCI notation. Castling moves are represented as a move of the king to its new position.

Warning: Using standard notation for castling moves in Chess960 may create moves that are illegal or moves that can be confused with king moves.

Examples

use shakmaty::uci::Uci;
use shakmaty::{Move, Square};

let m = Move::Castle {
    king: Square::E8,
    rook: Square::H8,
};

let uci = Uci::from_standard(&m);
assert_eq!(uci.to_string(), "e8g8");

pub fn from_chess960(m: &Move) -> Uci[src]

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.

Examples

use shakmaty::uci::Uci;
use shakmaty::{Move, Square};

let m = Move::Castle {
    king: Square::E8,
    rook: Square::H8,
};

let uci = Uci::from_chess960(&m);
assert_eq!(uci.to_string(), "e8h8");

pub fn from_move(m: &Move, mode: CastlingMode) -> Uci[src]

pub fn to_move<P: Position>(&self, pos: &P) -> Result<Move, IllegalUciError>[src]

Tries to convert the Uci to a legal Move in the context of a position.

Errors

Returns IllegalUciError if the move is not legal.

Trait Implementations

impl Clone for Uci[src]

impl Debug for Uci[src]

impl Display for Uci[src]

impl Eq for Uci[src]

impl FromStr for Uci[src]

type Err = ParseUciError

The associated error which can be returned from parsing.

impl Hash for Uci[src]

impl PartialEq<Uci> for Uci[src]

impl StructuralEq for Uci[src]

impl StructuralPartialEq for Uci[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.