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#[must_use]
65pub fn record_key(owner: &str, ty: &str) -> String {
66 if owner.is_empty() {
67 ty.to_owned()
68 } else {
69 format!("{owner}{}{ty}", yog_ids::sep::PATH)
70 }
71}
72
73#[must_use]
75pub fn owner_prefix(owner: &str) -> String {
76 format!("{owner}{}", yog_ids::sep::PATH)
77}