Struct pgn4::PGN4[][src]

pub struct PGN4 {
    pub bracketed: Vec<(String, String)>,
    pub turns: Vec<Turn>,
}
Expand description

Representation of pgn4 file

TODO: general description

Notably, Chess.com does not support variations within variations whereas this tool does. If you try to import a pgn4 with recursive variations into Chess.com, you will get errors.

Fields

bracketed: Vec<(String, String)>
Expand description

PGN4 files have a list of key value pairs in the beginning that specify variants, time control, and other metadata

turns: Vec<Turn>
Expand description

The game is stored as a list of Turns which hold up to 4 QuarterTurns each. Unfortunately, this cannot be simplified to a single list without compromising round-trip serilization or including enough logic to deduce which player’s turn it is.

If you need to follow sub-variations, please use a Visitor

Implementations

impl PGN4[src]

pub fn tag<'a>(&'a self, tag_name: &str) -> Option<&'a str>[src]

Searches for a tag and optionally returns a reference to it if found

pub fn variant(&self) -> Result<Variant, VariantError>[src]

Extract / parse the variant from a pgn4

pub fn ratings(&self) -> Option<[u16; 4]>[src]

If all four players are rated, parse all of the ratings.

pub fn players(&self) -> Option<[&str; 4]>[src]

If all players have names, return a reference to them

pub fn result(&self) -> GameResult[src]

If tag “Result” is present, parse it.

pub fn append_move(
    &mut self,
    path: &[usize],
    q: QuarterTurn
) -> Result<usize, ()>
[src]

Inserts q after path in self and returns the index of the alternative where the move was placed (0 for continuing the line).

Format for path is [ply forward] : [alternative index, plyforward]* In order to follow it, move to the next move path[0] times, then if there is more to path, go into alternative path[1]-1 and continue with path[2..] This is the format Chess.com uses to notate with

pub fn promote_to_mainline(&mut self, path: &[usize]) -> Result<(), ()>[src]

Switches the order of alternatives / main moves such that the given path ends up as the mainline

pub fn delete_from(&mut self, path: &[usize]) -> Result<(), ()>[src]

Deletes all further moves after path and path istself. Any alternatives to it remain.

Trait Implementations

impl Clone for PGN4[src]

fn clone(&self) -> PGN4[src]

Returns a copy of the value. Read more

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

Performs copy-assignment from source. Read more

impl Debug for PGN4[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Display for PGN4[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl FromStr for PGN4[src]

type Err = PGN4Error

The associated error which can be returned from parsing.

fn from_str(string: &str) -> Result<Self, Self::Err>[src]

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

impl PartialEq<PGN4> for PGN4[src]

fn eq(&self, other: &PGN4) -> bool[src]

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

fn ne(&self, other: &PGN4) -> bool[src]

This method tests for !=.

impl StructuralPartialEq for PGN4[src]

Auto Trait Implementations

impl RefUnwindSafe for PGN4

impl Send for PGN4

impl Sync for PGN4

impl Unpin for PGN4

impl UnwindSafe for PGN4

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

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

recently added

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

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

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

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.

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

Performs the conversion.

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.

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

Performs the conversion.