pub struct MemoryMappedFile { /* private fields */ }Expand description
Memory-mapped file wrapper
Implementations§
Source§impl MemoryMappedFile
impl MemoryMappedFile
Sourcepub fn new(
path: PathBuf,
config: MemoryMappedConfig,
) -> Result<Self, OptimizerError>
pub fn new( path: PathBuf, config: MemoryMappedConfig, ) -> Result<Self, OptimizerError>
Create a new memory-mapped file
Sourcepub fn open(
path: PathBuf,
config: MemoryMappedConfig,
) -> Result<Self, OptimizerError>
pub fn open( path: PathBuf, config: MemoryMappedConfig, ) -> Result<Self, OptimizerError>
Open an existing memory-mapped file
Sourcepub fn write(&mut self, data: &[u8]) -> Result<usize, OptimizerError>
pub fn write(&mut self, data: &[u8]) -> Result<usize, OptimizerError>
Write data to the memory-mapped file
Sourcepub fn read(
&mut self,
offset: usize,
length: usize,
) -> Result<Vec<u8>, OptimizerError>
pub fn read( &mut self, offset: usize, length: usize, ) -> Result<Vec<u8>, OptimizerError>
Read data from the memory-mapped file
Sourcepub fn write_at(
&mut self,
offset: usize,
data: &[u8],
) -> Result<(), OptimizerError>
pub fn write_at( &mut self, offset: usize, data: &[u8], ) -> Result<(), OptimizerError>
Overwrite data at a specific offset
Sourcepub fn sync(&mut self) -> Result<(), OptimizerError>
pub fn sync(&mut self) -> Result<(), OptimizerError>
Sync the file to disk
Auto Trait Implementations§
impl Freeze for MemoryMappedFile
impl RefUnwindSafe for MemoryMappedFile
impl Send for MemoryMappedFile
impl Sync for MemoryMappedFile
impl Unpin for MemoryMappedFile
impl UnsafeUnpin for MemoryMappedFile
impl UnwindSafe for MemoryMappedFile
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