selene_core/database/mergeable.rs
1use lunar_lib::database::{CompareAndSwapTransaction, CustomTransactionError, DatabaseEntry};
2
3pub trait Mergeable: DatabaseEntry {
4 type Err;
5
6 /// Merges [`Self`] into the `into` entry
7 ///
8 /// This means the identifier of `to` will be preserved, while [`Self`] is deleted
9 /// All references to [`Self`] should be relinked to `into`
10 ///
11 /// This function should be a single atomic transaction
12 fn tx_merge(
13 &self,
14 into: Self::Id,
15 cas_tx: &mut CompareAndSwapTransaction<Self::EntryDb>,
16 ) -> Result<(), CustomTransactionError<Self::Err>>;
17}