composable_indexes/core/
index.rs1pub use super::Key;
2
3#[derive(Clone, Copy)]
10pub struct Seal {
11 _seal: (),
12}
13
14pub(crate) const SEAL: Seal = Seal { _seal: () };
15
16impl Seal {
17 #[cfg(feature = "testutils")]
18 pub fn unsafe_mk_seal() -> Self {
19 Seal { _seal: () }
20 }
21}
22
23pub trait Index<T> {
25 fn insert(&mut self, seal: Seal, op: &Insert<T>);
26
27 fn remove(&mut self, seal: Seal, op: &Remove<T>);
28
29 #[inline]
30 fn update(&mut self, seal: Seal, op: &Update<T>) {
31 self.remove(
32 seal,
33 &Remove {
34 key: op.key,
35 existing: op.existing,
36 },
37 );
38 self.insert(
39 seal,
40 &Insert {
41 key: op.key,
42 new: op.new,
43 },
44 );
45 }
46}
47
48#[derive(Clone)]
49pub struct Insert<'t, In> {
50 pub key: Key,
51 pub new: &'t In,
52}
53
54#[derive(Clone)]
55pub struct Update<'t, In> {
56 pub key: Key,
57 pub new: &'t In,
58 pub existing: &'t In,
59}
60
61#[derive(Clone)]
62pub struct Remove<'t, In> {
63 pub key: Key,
64 pub existing: &'t In,
65}