Enum sgf_parse::SgfProp [−][src]
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)
MN(i64)
W(Move)
PL(Color)
C(Text)
DM(Double)
GB(Double)
GW(Double)
HO(Double)
N(SimpleText)
UC(Double)
V(f64)
BM(Double)
TE(Double)
LB(HashSet<(Point, SimpleText)>)
AP((SimpleText, SimpleText))
CA(SimpleText)
FF(i64)
GM(i64)
ST(i64)
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)
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
impl RefUnwindSafe for SgfProp
[src]
impl Send for SgfProp
[src]
impl Sync for SgfProp
[src]
impl Unpin for SgfProp
[src]
impl UnwindSafe for SgfProp
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
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]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,