Skip to main content

Game

Struct Game 

Source
pub struct Game { /* private fields */ }
Expand description

A game tree and its game-level data.

Implementations§

Source§

impl Game

Source

pub fn from_chessbase(encoded: Game) -> Result<Self>

Source§

impl Game

Source

pub fn from_pgn(pgn: Pgn) -> Result<Self>

Source

pub fn from_pgn_with(pgn: Pgn, import: &Import) -> Result<Self>

Source§

impl Game

Source

pub fn undo(&mut self) -> Result<()>

Source

pub fn restore(&mut self, revision: usize) -> Result<()>

Source

pub fn patch(&mut self, patch: Patch) -> Result<()>

Source§

impl Game

Source

pub fn play(&self, slot: MoveSlot) -> Result<MoveRef<'_>>

Source

pub fn play_mut(&mut self, slot: MoveSlot) -> Result<MoveMut<'_>>

Source

pub fn position(&self, slot: PositionSlot) -> Result<PositionRef<'_>>

Source

pub fn position_mut(&mut self, slot: PositionSlot) -> Result<PositionMut<'_>>

Source

pub const fn start(&self) -> PositionRef<'_>

Source

pub const fn start_mut(&mut self) -> PositionMut<'_>

Source

pub const fn into_cursor(self) -> Cursor

Source

pub const fn cursor(&self) -> CursorRef<'_>

Source

pub const fn cursor_mut(&mut self) -> CursorMut<'_>

Source

pub const fn order(&self, slot: PositionSlot) -> Order<'_>

Source§

impl Game

Source

pub fn merge(&mut self, other: &Game) -> Result<()>

Merges another game with the same starting position, retaining this game’s metadata.

Source§

impl Game

Source

pub fn new(position: Position) -> Self

Source

pub fn with_mode(position: Position, mode: Mode) -> Option<Self>

Source

pub fn chess(position: Position) -> Option<Self>

Source

pub fn freestyle(position: Position) -> Self

Source

pub fn reslot(&mut self, layout: Layout) -> Reslot

Reassigns move slots in a prescribed layout and returns the old-to-new mapping.

Tracked changes are discarded, as they use the the old slots. Change tracking remains enabled or disabled as configured.

Source

pub const fn mode(&self) -> Mode

Source

pub const fn tracks_changes(&self) -> bool

Source

pub fn track_changes(&mut self, on: bool)

Source

pub fn changes(&self) -> Option<&[Change]>

Source

pub fn revisions(&self) -> Option<usize>

Source

pub fn clear_evaluations(&mut self)

Source

pub const fn public(&self) -> &GamePublic

Source

pub const fn title(&self) -> Option<&Text>

Source

pub const fn orientation(&self) -> Player

Source

pub const fn outcome(&self) -> Outcome

Source

pub const fn roster(&self) -> &Roster

Source

pub const fn tags(&self) -> &[Tag]

Source

pub fn set_orientation(&mut self, orientation: Player)

Source

pub fn set_title(&mut self, title: Option<Text>)

Source

pub fn set_outcome(&mut self, outcome: Outcome)

Source

pub fn update_roster(&mut self, update: impl FnOnce(&mut Roster))

Source

pub fn update_tags(&mut self, update: impl FnOnce(&mut Vec<Tag>))

Source

pub fn update_public(&mut self, update: impl FnOnce(&mut GamePublic))

Source§

impl Game

Source

pub fn key(&self) -> Key

Trait Implementations§

Source§

impl<'a> Arbitrary<'a> for Game

Source§

fn arbitrary(input: &mut Unstructured<'a>) -> Result<Self>

Generate an arbitrary value of Self from the given unstructured data. Read more
§

fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
§

fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

impl Clone for Game

Source§

fn clone(&self) -> Game

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl From<Game> for Pgn

Source§

fn from(game: Game) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Game

Source§

fn eq(&self, other: &Game) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Game

Source§

impl TryFrom<Game> for Game

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(encoded: Game) -> Result<Self>

Performs the conversion.
Source§

impl TryFrom<Pgn> for Game

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(pgn: Pgn) -> Result<Self>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for Game

§

impl RefUnwindSafe for Game

§

impl Send for Game

§

impl Sync for Game

§

impl Unpin for Game

§

impl UnsafeUnpin for Game

§

impl UnwindSafe for Game

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.