pub struct Slot<T, B = PlatformStore>{ /* private fields */ }Expand description
Last accepted in-memory value plus its durable generation. Invalid/future files are preserved until reset() is explicitly requested by the application.
Implementations§
Source§impl<T, B> Slot<T, B>
impl<T, B> Slot<T, B>
pub fn with_backend( owner: &str, name: &str, default: T, backend: B, ) -> Result<Slot<T, B>, StorageError>
pub fn value(&self) -> &T
pub fn generation(&self) -> u64
pub fn status(&self) -> LoadStatus
Sourcepub fn validate_loaded<R>(
&mut self,
validate: impl FnOnce(&T) -> Result<R, SaveError>,
) -> Result<R, StorageError>
pub fn validate_loaded<R>( &mut self, validate: impl FnOnce(&T) -> Result<R, SaveError>, ) -> Result<R, StorageError>
Apply validation that needs the current level/rules. Failure protects the original bytes from automatic overwrite; a constructed result can be staged.
Sourcepub fn commit(&mut self, next: T) -> Result<(), StorageError>
pub fn commit(&mut self, next: T) -> Result<(), StorageError>
Validate/serialize a replacement and commit it atomically. Failed writes retain the accepted memory value; corrupt/future files are never auto-overwritten.
Sourcepub fn reset(&mut self, next: T) -> Result<(), StorageError>
pub fn reset(&mut self, next: T) -> Result<(), StorageError>
Explicitly replace a rejected save with a validated new value.
Auto Trait Implementations§
impl<T, B> Freeze for Slot<T, B>
impl<T, B> RefUnwindSafe for Slot<T, B>where
T: RefUnwindSafe,
B: RefUnwindSafe,
impl<T, B> Send for Slot<T, B>
impl<T, B> Sync for Slot<T, B>
impl<T, B> Unpin for Slot<T, B>
impl<T, B> UnwindSafe for Slot<T, B>where
T: UnwindSafe,
B: UnwindSafe,
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