pub struct MemoryMappedFile { /* private fields */ }
Expand description
Memory-mapped file wrapper providing cross-platform file access
Implementations§
Source§impl MemoryMappedFile
impl MemoryMappedFile
Sourcepub fn new(filepath: PathBuf, size: usize) -> SparseResult<Self>
pub fn new(filepath: PathBuf, size: usize) -> SparseResult<Self>
Create a new memory-mapped file
Sourcepub fn new_with_config(
filepath: PathBuf,
size: usize,
config: MemoryMappingConfig,
) -> SparseResult<Self>
pub fn new_with_config( filepath: PathBuf, size: usize, config: MemoryMappingConfig, ) -> SparseResult<Self>
Create memory-mapped file with configuration
Sourcepub fn open(filepath: PathBuf) -> SparseResult<Self>
pub fn open(filepath: PathBuf) -> SparseResult<Self>
Open existing memory-mapped file
Sourcepub fn read_at(
&mut self,
offset: usize,
buffer: &mut [u8],
) -> SparseResult<usize>
pub fn read_at( &mut self, offset: usize, buffer: &mut [u8], ) -> SparseResult<usize>
Read data from the mapped file at offset
Sourcepub fn write_at(&mut self, offset: usize, data: &[u8]) -> SparseResult<usize>
pub fn write_at(&mut self, offset: usize, data: &[u8]) -> SparseResult<usize>
Write data to the mapped file at offset
Sourcepub fn read_all(&mut self) -> SparseResult<Vec<u8>>
pub fn read_all(&mut self) -> SparseResult<Vec<u8>>
Read entire file contents
Sourcepub fn write_all(&mut self, data: &[u8]) -> SparseResult<()>
pub fn write_all(&mut self, data: &[u8]) -> SparseResult<()>
Write entire file contents
Sourcepub fn resize(&mut self, new_size: usize) -> SparseResult<()>
pub fn resize(&mut self, new_size: usize) -> SparseResult<()>
Resize the mapped file
Sourcepub fn flush(&self) -> SparseResult<()>
pub fn flush(&self) -> SparseResult<()>
Flush data to disk
Sourcepub fn flush_data(&self) -> SparseResult<()>
pub fn flush_data(&self) -> SparseResult<()>
Flush data to disk (metadata only)
Sourcepub fn access_count(&self) -> u64
pub fn access_count(&self) -> u64
Get access count
Sourcepub fn reset_access_count(&mut self)
pub fn reset_access_count(&mut self)
Reset access count
Sourcepub fn metadata(&self) -> SparseResult<Metadata>
pub fn metadata(&self) -> SparseResult<Metadata>
Get file metadata
Sourcepub fn read_chunked<F>(
&mut self,
chunk_size: usize,
callback: F,
) -> SparseResult<()>
pub fn read_chunked<F>( &mut self, chunk_size: usize, callback: F, ) -> SparseResult<()>
Read data in chunks for better memory efficiency
Sourcepub fn write_chunked<F>(
&mut self,
chunk_size: usize,
data_provider: F,
) -> SparseResult<()>
pub fn write_chunked<F>( &mut self, chunk_size: usize, data_provider: F, ) -> SparseResult<()>
Write data in chunks for better memory efficiency
Sourcepub fn prefetch(&self, offset: usize, length: usize) -> SparseResult<()>
pub fn prefetch(&self, offset: usize, length: usize) -> SparseResult<()>
Prefetch data into memory (hint to OS)
Sourcepub fn advise_access_pattern(&self, pattern: AccessPattern) -> SparseResult<()>
pub fn advise_access_pattern(&self, pattern: AccessPattern) -> SparseResult<()>
Advise access pattern to OS
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MemoryMappedFile
impl RefUnwindSafe for MemoryMappedFile
impl Send for MemoryMappedFile
impl Sync for MemoryMappedFile
impl Unpin 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
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