pub struct PersistentBuff { /* private fields */ }
Expand description

Strut to request the persistent buff and manage it safely. When acquiring the buffer you need to validate/init it to a known sate.

Implementations

Take a managed version fo the persistent buff. Allow to check if the buffer is valid or not before usage. Note that vs the Self::take function, you will lose some bytes for storage of the marker.

Steal a managed version for the persistent buff without check. See Self::take_managed

Safety

Calling this function could allow to have two mutable reference to the same buffer. Make sure to only have one reference at a time to avoid multiple mutable reference.

Get the raw persistent slice.

Steal the raw persistent slice. Ignore if it was already taken or not.

Safety

Calling this function could allow to have two mutable reference to the same buffer. Make sure to only have one reference at a time to avoid multiple mutable reference.

Verify if the persistent buffer has valid data in it.

Get the buffer if the data is valid, if not, return None

Force reset the buffer to a known state via the closure, mark as valid and return the buffer

Check if the buffer is valid, if not call the provided closure. Then mark the buffer as valid and initialize it to a known state. This is to make sure the data in it is always “valid” and not garbage after a powerloss.

Mark the buffer as invalid

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.