[][src]Enum sgf_parse::SgfProp

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

Implementations

impl SgfProp[src]

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

Returns a new property parsed from the provided identifier and values

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;

// Prints "W"
let prop = SgfProp::new("W".to_string(), vec!["de".to_string()]).unwrap();
println!("Identifier: {}", prop.identifier());
// Prints "FOO"
let prop = SgfProp::new("FOO".to_string(), vec!["de".to_string()]).unwrap();
println!("Identifier: {}", prop.identifier());

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

Returns the PropertyType associated with the property.

Examples

use sgf_parse::SgfProp;

// Prints "W"
let prop = SgfProp::new("W".to_string(), vec!["de".to_string()]).unwrap();
println!("Identifier: {}", prop.identifier());
// Prints "FOO"
let prop = SgfProp::new("FOO".to_string(), vec!["de".to_string()]).unwrap();
println!("Identifier: {}", prop.identifier());

Trait Implementations

impl Clone for SgfProp[src]

impl Debug for SgfProp[src]

Auto Trait Implementations

impl RefUnwindSafe for SgfProp

impl Send for SgfProp

impl Sync for SgfProp

impl Unpin for SgfProp

impl UnwindSafe for SgfProp

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, 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.