pub struct StateFile { /* private fields */ }Expand description
Plain atomic-rename state file: 24-byte header [magic:8, schema:u32, len:u32, xxh64:u64] +
payload, where xxh64 covers both the 16-byte header prefix and the payload bytes.
Implementations§
Source§impl StateFile
impl StateFile
pub fn open( path: impl AsRef<Path>, schema_version: u32, ) -> Result<Self, PersistenceError>
pub fn open_with_sync( path: impl AsRef<Path>, schema_version: u32, sync_on_save: bool, ) -> Result<Self, PersistenceError>
pub fn new_in_memory(schema_version: u32) -> Self
pub fn path(&self) -> Option<&Path>
pub fn schema_version(&self) -> u32
pub fn generation(&self) -> u64
pub fn recovery_stats(&self) -> StateRecoveryStats
pub fn encode_envelope( schema_version: u32, payload: &[u8], ) -> Result<Vec<u8>, PersistenceError>
pub fn decode_envelope( bytes: &[u8], expected_schema: u32, ) -> Result<&[u8], PersistenceError>
Sourcepub fn load(&self) -> Result<Option<Vec<u8>>, PersistenceError>
pub fn load(&self) -> Result<Option<Vec<u8>>, PersistenceError>
Returns the validated payload read on open or written by the last Self::save without
re-reading or re-hashing the file from disk.
pub fn save( &mut self, payload: &[u8], ) -> Result<StateSaveOutcome, PersistenceError>
Sourcepub fn quarantine_corrupt(&mut self) -> Result<(), PersistenceError>
pub fn quarantine_corrupt(&mut self) -> Result<(), PersistenceError>
Moves a payload-corrupt state file aside to <file>.corrupt and clears cached state.
pub fn reset(&mut self) -> Result<(), PersistenceError>
Auto Trait Implementations§
impl Forget for StateFile
impl Freeze for StateFile
impl Move for StateFile
impl RefUnwindSafe for StateFile
impl Send for StateFilewhere
RawVecInner: Send,
impl Sync for StateFilewhere
RawVecInner: Sync,
impl Unpin for StateFile
impl UnsafeUnpin for StateFile
impl UnwindSafe for StateFilewhere
RawVecInner: 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