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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl SgfProp for sgf_parse::go::Prop

Source§

impl SgfProp for sgf_parse::unknown_game::Prop