1use yog_data::Schema;
5
6use crate::cell::Kind;
7
8#[derive(Schema, Clone, Debug, PartialEq, Eq)]
10pub struct FieldSpec {
11 pub name: String,
12 pub fact: Option<String>,
15 pub kind: u8,
17 pub count: u32,
19}
20
21impl FieldSpec {
22 pub fn kind(&self) -> Option<Kind> {
23 Kind::from_code(self.kind)
24 }
25
26 pub fn width(&self) -> Option<u32> {
28 Some(self.kind()?.size() as u32 * self.count)
29 }
30}
31
32#[derive(Schema, Clone, Debug, PartialEq, Eq)]
34pub struct MirrorSpec {
35 pub name: String,
37 pub space: String,
39 pub fields: Vec<FieldSpec>,
40}
41
42#[derive(Schema, Copy, Clone, Debug, PartialEq, Eq)]
44pub enum Rate {
45 Every(u32),
47 Changes,
49}
50
51#[derive(Copy, Clone, Debug, PartialEq, Eq)]
53pub struct Linked {
54 pub column: *const yog_abi::YogColumn,
56 pub depth: u8,
59}
60
61#[derive(Clone, Debug)]
63pub struct Declared {
64 pub id: u32,
65 pub space: *const yog_abi::YogKeySpace,
67 pub rows: *const yog_abi::YogColumn,
69 pub fields: Vec<Option<Linked>>,
71}
72
73#[derive(Clone, Debug, PartialEq, Eq)]
76pub struct Due {
77 pub writer: u32,
78 pub mirror: yog_sync::Arc<str>,
79 pub fields: u64,
80 pub space: u64,
82 pub space_name: yog_sync::Arc<str>,
84 pub rows: u64,
86 pub columns: std::ops::Range<usize>,
88 pub scopes: std::ops::Range<usize>,
90}
91
92#[derive(Clone, Debug, Default)]
95pub struct DueList {
96 pub turns: Vec<Due>,
97 columns: Vec<u64>,
98 scopes: Vec<yog_sync::Arc<[u8]>>,
99}
100
101impl DueList {
102 pub fn columns(&self, due: &Due) -> &[u64] {
104 &self.columns[due.columns.clone()]
105 }
106
107 pub fn scopes(&self, due: &Due) -> &[yog_sync::Arc<[u8]>] {
109 &self.scopes[due.scopes.clone()]
110 }
111
112 pub(crate) fn clear(&mut self) {
113 self.turns.clear();
114 self.columns.clear();
115 self.scopes.clear();
116 }
117
118 pub(crate) fn push_scope(&mut self, scope: yog_sync::Arc<[u8]>) {
119 self.scopes.push(scope);
120 }
121
122 pub(crate) fn next_scope(&self) -> usize {
123 self.scopes.len()
124 }
125
126 pub(crate) fn push_column(&mut self, column: u64) {
127 self.columns.push(column);
128 }
129
130 pub(crate) fn next_column(&self) -> usize {
131 self.columns.len()
132 }
133}