use crate::db::{data::StorageKey, index::IndexKey};
#[derive(Debug)]
pub(in crate::db) struct IndexMutationPlan {
pub(in crate::db) groups: Vec<IndexDeltaGroup>,
}
impl IndexMutationPlan {
pub(in crate::db) const fn new(groups: Vec<IndexDeltaGroup>) -> Self {
Self { groups }
}
}
#[derive(Debug)]
pub(in crate::db) struct IndexDeltaGroup {
pub(in crate::db) index_store: &'static str,
pub(in crate::db) index_fields: String,
pub(in crate::db) deltas: Vec<IndexDelta>,
}
impl IndexDeltaGroup {
#[must_use]
pub(in crate::db) const fn new(
index_store: &'static str,
index_fields: String,
deltas: Vec<IndexDelta>,
) -> Self {
Self {
index_store,
index_fields,
deltas,
}
}
}
#[derive(Debug)]
pub(in crate::db) enum IndexDelta {
Remove(IndexMembershipDelta),
Insert(IndexMembershipDelta),
}
impl IndexDelta {
#[must_use]
pub(in crate::db) const fn remove(key: IndexKey, primary_key: StorageKey) -> Self {
Self::Remove(IndexMembershipDelta { key, primary_key })
}
#[must_use]
pub(in crate::db) const fn insert(key: IndexKey, primary_key: StorageKey) -> Self {
Self::Insert(IndexMembershipDelta { key, primary_key })
}
}
#[derive(Debug)]
pub(in crate::db) struct IndexMembershipDelta {
pub(in crate::db) key: IndexKey,
pub(in crate::db) primary_key: StorageKey,
}