sgf_parse/
unknown_game.rs1use crate::props::parse::FromCompressedList;
11use crate::props::{PropertyType, SgfPropError, ToSgf};
12use crate::{InvalidNodeError, SgfProp};
13use std::collections::HashSet;
14
15sgf_prop! {
16 Prop, String, String, String,
17 { }
18}
19
20pub type Point = String;
22
23pub type Stone = String;
25
26pub type Move = String;
28
29impl SgfProp for Prop {
30 type Point = Point;
31 type Stone = Stone;
32 type Move = Move;
33
34 fn new(identifier: String, values: Vec<String>) -> Self {
35 Self::parse_general_prop(identifier, values)
36 }
37
38 fn identifier(&self) -> String {
39 match self.general_identifier() {
40 Some(identifier) => identifier,
41 None => panic!("Unimplemented identifier for {:?}", self),
42 }
43 }
44
45 fn property_type(&self) -> Option<PropertyType> {
46 self.general_property_type()
47 }
48
49 fn validate_properties(properties: &[Self], is_root: bool) -> Result<(), InvalidNodeError> {
50 Self::general_validate_properties(properties, is_root)
51 }
52}
53
54impl std::fmt::Display for Prop {
55 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
56 let prop_string = match self.serialize_prop_value() {
57 Some(s) => s,
58 None => panic!("Unimplemented identifier for {:?}", self),
59 };
60 write!(f, "{}[{}]", self.identifier(), prop_string)
61 }
62}
63
64impl FromCompressedList for String {
65 fn from_compressed_list(ul: &Self, lr: &Self) -> Result<HashSet<Self>, SgfPropError> {
66 let mut points = HashSet::new();
70 points.insert(format!("{ul}:{lr}"));
71 Ok(points)
72 }
73}
74
75impl ToSgf for String {
76 fn to_sgf(&self) -> String {
77 self.to_owned()
78 }
79}