[][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).

Methods

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_move<P: Position>(pos: &P, m: &Move) -> Uci[src]

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]

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, IllegalMoveError>[src]

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

Errors

Returns IllegalMoveError if the move is not legal.

Trait Implementations

impl Clone for Uci[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Eq for Uci[src]

impl PartialEq<Uci> for Uci[src]

impl Hash for Uci[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Display for Uci[src]

impl Debug for Uci[src]

impl FromStr for Uci[src]

type Err = ParseUciError

The associated error which can be returned from parsing.

Auto Trait Implementations

impl Send for Uci

impl Unpin for Uci

impl Sync for Uci

impl UnwindSafe for Uci

impl RefUnwindSafe for Uci

Blanket Implementations

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

type Owned = T

The resulting type after obtaining ownership.

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

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

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.

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

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

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