yog_event/planes/system/
storage.rs1use yog_data::Schema;
7use yog_data::with::Raw;
8
9#[derive(Debug, Clone, PartialEq, Eq, Schema)]
14pub struct Where {
15 pub scope: String,
16 pub instance: String,
17}
18
19#[derive(Debug, Clone, Schema)]
22pub struct Read {
23 pub mod_id: String,
24 pub at: Where,
25 pub owner: String,
26 pub ty: String,
27}
28
29#[derive(Debug, Clone, Default, Schema)]
31pub struct Record {
32 #[data(with = "Raw")]
33 pub bytes: Vec<u8>,
34}
35
36#[derive(Debug, Clone, Schema)]
38pub struct Write {
39 pub mod_id: String,
40 pub at: Where,
41 pub owner: String,
42 pub ty: String,
43 #[data(with = "Raw")]
44 pub bytes: Vec<u8>,
45}
46
47#[derive(Debug, Clone, Schema)]
49pub struct Remove {
50 pub mod_id: String,
51 pub at: Where,
52 pub owner: String,
53 pub ty: Option<String>,
54}
55
56#[derive(Debug, Clone, Schema)]
58pub struct Owners {
59 pub mod_id: String,
60 pub at: Where,
61}
62
63#[derive(Debug, Clone, PartialEq, Eq, Schema)]
68pub struct SyncedRow {
69 pub kind: String,
70 pub owner: String,
71 pub key: String,
72 #[data(with = "Raw")]
73 pub bytes: Vec<u8>,
74}
75
76#[must_use]
78pub fn record_key(owner: &str, ty: &str) -> String {
79 if owner.is_empty() {
80 ty.to_owned()
81 } else {
82 format!("{owner}{}{ty}", yog_ids::sep::PATH)
83 }
84}
85
86#[must_use]
88pub fn owner_prefix(owner: &str) -> String {
89 format!("{owner}{}", yog_ids::sep::PATH)
90}