semilattice_database_session/session/
operation.rs

1use std::{
2    num::{NonZeroI32, NonZeroU32},
3    sync::Arc,
4};
5
6use hashbrown::HashMap;
7use semilattice_database::{Activity, FieldName, Term};
8
9use crate::CollectionRow;
10
11#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Default)]
12pub enum SessionOperation {
13    #[default]
14    New,
15    Update,
16    Delete,
17}
18
19#[derive(Debug)]
20pub enum Depends {
21    Default,
22    Overwrite(Vec<(Arc<String>, CollectionRow)>),
23}
24
25#[derive(Debug)]
26pub struct Pend {
27    pub key: Arc<String>,
28    pub records: Vec<SessionRecord>,
29}
30
31#[derive(Debug)]
32pub enum SessionRecord {
33    Update {
34        collection_id: NonZeroI32,
35        row: Option<NonZeroU32>,
36        activity: Activity,
37        term_begin: Term,
38        term_end: Term,
39        fields: HashMap<FieldName, Vec<u8>>,
40        depends: Depends,
41        pends: Vec<Pend>,
42    },
43    Delete {
44        collection_id: NonZeroI32,
45        row: NonZeroU32,
46    },
47}