Struct Slot

Source
pub struct Slot<T, B = PlatformStore>
where T: SaveData, B: Backend,
{ /* 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> Slot<T>
where T: SaveData,

Source

pub fn open( owner: &str, name: &str, default: T, ) -> Result<Slot<T>, StorageError>

Source§

impl<T, B> Slot<T, B>
where T: SaveData, B: Backend,

Source

pub fn with_backend( owner: &str, name: &str, default: T, backend: B, ) -> Result<Slot<T, B>, StorageError>

Source

pub fn value(&self) -> &T

Source

pub fn generation(&self) -> u64

Source

pub fn status(&self) -> LoadStatus

Source

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.

Source

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.

Source

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>
where T: Freeze, B: Freeze,

§

impl<T, B> RefUnwindSafe for Slot<T, B>

§

impl<T, B> Send for Slot<T, B>
where T: Send, B: Send,

§

impl<T, B> Sync for Slot<T, B>
where T: Sync, B: Sync,

§

impl<T, B> Unpin for Slot<T, B>
where T: Unpin, B: Unpin,

§

impl<T, B> UnwindSafe for Slot<T, B>
where T: UnwindSafe, B: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.