1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use serde::de::DeserializeOwned;
use serde::Serialize;
use std::collections::HashSet;
use std::fmt::Debug;
use std::hash::Hash;
pub trait Track: Copy + Debug + PartialEq + Sized {
fn do_split(&self) -> bool;
fn do_open_split(&self) -> bool;
fn supports_text(&self) -> bool;
fn allowed_in_root(&self) -> bool;
fn is_object(&self) -> bool;
fn parents(&self) -> Vec<Self>;
fn ancestors(&self) -> Vec<Self>;
}
pub trait Schema: Clone + Debug + PartialEq {
type Track: Track + Sized;
type GroupProperties: Sized + Clone + Debug + Serialize + PartialEq + DeserializeOwned;
type CharsProperties: Sized
+ Clone
+ Debug
+ Serialize
+ PartialEq
+ DeserializeOwned
+ Default
+ StyleTrait;
fn attrs_eq(a: &Self::GroupProperties, b: &Self::GroupProperties) -> bool;
fn track_type_from_attrs(attrs: &Self::GroupProperties) -> Option<Self::Track>;
fn merge_attrs(
a: &Self::GroupProperties,
b: &Self::GroupProperties,
) -> Option<Self::GroupProperties>;
}
pub trait StyleTrait: Sized {
type Style: Sized + Clone + PartialEq + Hash;
fn styles(&self) -> HashSet<Self::Style>;
fn is_empty(&self) -> bool;
fn extend(&mut self, set: &Self);
fn remove(&mut self, set: &Self);
}