Enum sgf_parse::SgfProp[][src]

pub enum SgfProp {
    B(Move),
    KO,
    MN(i64),
    W(Move),
    AB(HashSet<Point>),
    AE(HashSet<Point>),
    AW(HashSet<Point>),
    PL(Color),
    C(Text),
    DM(Double),
    GB(Double),
    GW(Double),
    HO(Double),
    N(SimpleText),
    UC(Double),
    V(f64),
    BM(Double),
    DO,
    IT,
    TE(Double),
    AR(HashSet<(Point, Point)>),
    CR(HashSet<Point>),
    DD(HashSet<Point>),
    LB(HashSet<(Point, SimpleText)>),
    LN(HashSet<(Point, Point)>),
    MA(HashSet<Point>),
    SL(HashSet<Point>),
    SQ(HashSet<Point>),
    TR(HashSet<Point>),
    AP((SimpleText, SimpleText)),
    CA(SimpleText),
    FF(i64),
    GM(i64),
    ST(i64),
    SZ((u8, u8)),
    HA(i64),
    KM(f64),
    AN(SimpleText),
    BR(SimpleText),
    BT(SimpleText),
    CP(SimpleText),
    DT(SimpleText),
    EV(SimpleText),
    GN(SimpleText),
    GC(Text),
    ON(SimpleText),
    OT(SimpleText),
    PB(SimpleText),
    PC(SimpleText),
    PW(SimpleText),
    RE(SimpleText),
    RO(SimpleText),
    RU(SimpleText),
    SO(SimpleText),
    TM(f64),
    US(SimpleText),
    WR(SimpleText),
    WT(SimpleText),
    BL(f64),
    OB(i64),
    OW(i64),
    WL(f64),
    FG(Option<(i64, SimpleText)>),
    PM(i64),
    VW(HashSet<Point>),
    TB(HashSet<Point>),
    TW(HashSet<Point>),
    Unknown(StringVec<String>),
    Invalid(StringVec<String>),
}

An SGF Property with identifier and value.

All general properties from the SGF specification and all go specific properties will return the approprite enum instance with parsed data. Unrecognized properties, or properties from other games will return Unknown(identifier, values).

See Property Value Types for a list of types recognized by SGF. For parsing purposes the following mappings are used:

Variants

B(Move)
KO
MN(i64)
W(Move)
PL(Color)
C(Text)
DM(Double)
GB(Double)
GW(Double)
HO(Double)
UC(Double)
V(f64)
BM(Double)
DO
IT
TE(Double)
FF(i64)
GM(i64)
ST(i64)
SZ((u8, u8))
HA(i64)
KM(f64)
GC(Text)
TM(f64)
BL(f64)
OB(i64)
OW(i64)
WL(f64)
PM(i64)
Unknown(StringVec<String>)
Invalid(StringVec<String>)

Implementations

impl SgfProp[src]

pub fn new(identifier: String, values: Vec<String>) -> Self[src]

Returns a new property parsed from the provided identifier and values

Errors

If the identifier is a recognized SGF FF[4] property type and the provided values aren't correct for that property type, then an error is returned.

Examples

use sgf_parse::SgfProp;

// SgfProp::B(Point{ x: 2, y: 3 }
let prop = SgfProp::new("B".to_string(), vec!["cd".to_string()]);
// SgfProp::AB(vec![Point{ x: 2, y: 3 }, Point { x: 3, y: 3 }])
let prop = SgfProp::new("AB".to_string(), vec!["cd".to_string(), "dd".to_string()]);
// SgfProp::Unknown("FOO", vec!["Text"])
let prop = SgfProp::new("FOO".to_string(), vec!["Text".to_string()]);

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

Returns a the identifier associated with the SgfProp.

Examples

use sgf_parse::SgfProp;

let prop = SgfProp::new("W".to_string(), vec!["de".to_string()]);
assert_eq!(prop.identifier(), "W");
let prop = SgfProp::new("FOO".to_string(), vec!["de".to_string()]);
assert_eq!(prop.identifier(), "FOO");

pub fn property_type(&self) -> Option<PropertyType>[src]

Returns the PropertyType associated with the property.

Examples

use sgf_parse::{SgfProp, PropertyType};

let prop = SgfProp::new("W".to_string(), vec!["de".to_string()]);
assert_eq!(prop.property_type(), Some(PropertyType::Move));
let prop = SgfProp::new("FOO".to_string(), vec!["de".to_string()]);
assert_eq!(prop.property_type(), None);

Trait Implementations

impl Clone for SgfProp[src]

impl Debug for SgfProp[src]

impl Display for SgfProp[src]

impl PartialEq<SgfProp> for SgfProp[src]

impl StructuralPartialEq for SgfProp[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.