pub struct MemoryMappedStateStorage { /* private fields */ }Expand description
Memory-mapped optimizer state storage
Implementations§
Source§impl MemoryMappedStateStorage
impl MemoryMappedStateStorage
Sourcepub fn new(config: MemoryMappedConfig) -> Result<Self, OptimizerError>
pub fn new(config: MemoryMappedConfig) -> Result<Self, OptimizerError>
Create a new memory-mapped state storage
Sourcepub fn store<T: Serialize>(
&mut self,
key: &str,
data: &T,
) -> Result<(), OptimizerError>
pub fn store<T: Serialize>( &mut self, key: &str, data: &T, ) -> Result<(), OptimizerError>
Store optimizer state data
Sourcepub fn store_raw(
&mut self,
key: &str,
data: &[u8],
data_type: &str,
) -> Result<(), OptimizerError>
pub fn store_raw( &mut self, key: &str, data: &[u8], data_type: &str, ) -> Result<(), OptimizerError>
Store raw bytes
Sourcepub fn load<T: DeserializeOwned>(
&mut self,
key: &str,
) -> Result<Option<T>, OptimizerError>
pub fn load<T: DeserializeOwned>( &mut self, key: &str, ) -> Result<Option<T>, OptimizerError>
Load optimizer state data
Sourcepub fn load_raw(&mut self, key: &str) -> Result<Option<Vec<u8>>, OptimizerError>
pub fn load_raw(&mut self, key: &str) -> Result<Option<Vec<u8>>, OptimizerError>
Load raw bytes
Sourcepub fn update<T: Serialize>(
&mut self,
key: &str,
data: &T,
) -> Result<(), OptimizerError>
pub fn update<T: Serialize>( &mut self, key: &str, data: &T, ) -> Result<(), OptimizerError>
Update existing state data
Sourcepub fn update_raw(
&mut self,
key: &str,
data: &[u8],
) -> Result<(), OptimizerError>
pub fn update_raw( &mut self, key: &str, data: &[u8], ) -> Result<(), OptimizerError>
Update raw bytes
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Check if a key exists
Sourcepub fn statistics(&self) -> StorageStatistics
pub fn statistics(&self) -> StorageStatistics
Get storage statistics
Sourcepub fn sync_all(&mut self) -> Result<(), OptimizerError>
pub fn sync_all(&mut self) -> Result<(), OptimizerError>
Sync all files to disk
Sourcepub fn compact(&mut self) -> Result<(), OptimizerError>
pub fn compact(&mut self) -> Result<(), OptimizerError>
Compact storage by removing unused space
Auto Trait Implementations§
impl Freeze for MemoryMappedStateStorage
impl RefUnwindSafe for MemoryMappedStateStorage
impl Send for MemoryMappedStateStorage
impl Sync for MemoryMappedStateStorage
impl Unpin for MemoryMappedStateStorage
impl UnsafeUnpin for MemoryMappedStateStorage
impl UnwindSafe for MemoryMappedStateStorage
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more