pub struct Replacer { /* private fields */ }Expand description
Whole-history replacement authority without append authority.
Candidates are fully owned before locking. A successful replacement swaps the complete vector and advances the version once.
ⓘ
use reef_core::transcript::store;
let replace = store::Store::new().replacer();
replace.append_batch(Vec::new());Implementations§
Source§impl Replacer
impl Replacer
Sourcepub fn replace(&self, items: Vec<Item>) -> Result<Version, Error>
pub fn replace(&self, items: Vec<Item>) -> Result<Version, Error>
Atomically replaces all items and advances the version by one.
§Errors
Error::VersionOverflow if the store already stands at
Version::MAX, and Error::Poisoned if a writer panicked while
holding the store lock. A failed replacement swaps nothing: the previous
history is still the whole history.
Sourcepub fn replace_if_version(
&self,
items: Vec<Item>,
expected: Version,
) -> Result<Version, Error>
pub fn replace_if_version( &self, items: Vec<Item>, expected: Version, ) -> Result<Version, Error>
Atomically replaces all items only when the live version is expected.
A conflict returns the expected and actual versions without overwriting the concurrent winner.
§Errors
Error::VersionConflict, reporting bothexpectedand the version observed under the commit lock, if another writer advanced the store after the caller readexpected. This is the check that makes a compaction safe to attempt concurrently: the candidate is discarded rather than overwriting work the caller never saw.Error::VersionOverflowif the store already stands atVersion::MAX. The conflict check runs first.Error::Poisonedif a writer panicked while holding the store lock.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Replacer
impl RefUnwindSafe for Replacer
impl Send for Replacer
impl Sync for Replacer
impl Unpin for Replacer
impl UnsafeUnpin for Replacer
impl UnwindSafe for Replacer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more