Trait sgf_parse::SgfProp[][src]

pub trait SgfProp: Debug + Display + Sized + Clone + Sealed {
    type Point: Debug + Clone + PartialEq + Eq + Hash + ToSgf;
    type Stone: Debug + Clone + PartialEq + Eq + Hash + ToSgf;
    type Move: Debug + Clone + PartialEq + Eq + ToSgf;
    fn new(identifier: String, values: Vec<String>) -> Self;
fn identifier(&self) -> String;
fn property_type(&self) -> Option<PropertyType>;
fn validate_properties(
        properties: &[Self],
        is_root: bool
    ) -> Result<(), InvalidNodeError>; }
Expand description

A type that can be used for properties in an SgfNode.

This trait is sealed and cannot be implemented for types outside of sgf_parse.

Associated Types

Required methods

Returns a new property parsed from the provided identifier and values

Examples

use sgf_parse::SgfProp;
use sgf_parse::go::Prop;

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

Returns a the identifier associated with the SgfProp.

Examples

use sgf_parse::SgfProp;
use sgf_parse::go::Prop;

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

Returns the PropertyType associated with the property.

Examples

use sgf_parse::{PropertyType, SgfProp};
use sgf_parse::go::Prop;

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

Validates a set of properties.

Errors

Returns an error if the collection of properties isn’t valid.

Implementors