pub enum Uci {
    Normal {
        from: Square,
        to: Square,
        promotion: Option<Role>,
    },
    Put {
        role: Role,
        to: Square,
    },
    Null,
}
Expand description

A move as represented in the UCI protocol.

Variants

Normal

Fields

from: Square
to: Square
promotion: Option<Role>

A normal move, e.g. e2e4 or h2h1q.

Put

Fields

role: Role
to: Square

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

Null

A null move (0000).

Implementations

Parses a move in UCI notation.

Errors

Returns ParseUciError if uci is not syntactically valid.

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

let uci = Uci::from_ascii(b"e4e5")?;

assert_eq!(uci, Uci::Normal {
    from: Square::E4,
    to: Square::E5,
    promotion: None,
});

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::{Move, Square, uci::Uci};

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

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

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::{Move, Square, uci::Uci};

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

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

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

Feeds this value into the given Hasher. Read more

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

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.