Trait sgf_parse::SgfProp

source ·
pub trait SgfProp: Debug + Display + Sized + Clone + Eq + Sealed {
    type Point: Debug + Clone + PartialEq + Eq + Hash + ToSgf;
    type Stone: Debug + Clone + PartialEq + Eq + Hash + ToSgf;
    type Move: Debug + Clone + PartialEq + Eq + ToSgf;

    // Required methods
    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.

Required Associated Types§

source

type Point: Debug + Clone + PartialEq + Eq + Hash + ToSgf

source

type Stone: Debug + Clone + PartialEq + Eq + Hash + ToSgf

source

type Move: Debug + Clone + PartialEq + Eq + ToSgf

Required Methods§

source

fn new(identifier: String, values: Vec<String>) -> Self

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()]);
source

fn identifier(&self) -> 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");
source

fn property_type(&self) -> Option<PropertyType>

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);
source

fn validate_properties( properties: &[Self], is_root: bool ) -> Result<(), InvalidNodeError>

Validates a set of properties.

Errors

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

Implementors§

source§

impl SgfProp for sgf_parse::go::Prop

§

type Point = Point

§

type Stone = Point

§

type Move = Move

source§

impl SgfProp for sgf_parse::unknown_game::Prop