pub struct AsyncMmapFileMut { /* private fields */ }tokio only.Expand description
A writable memory map file.
There is 3 status of this struct:
- Disk: mmap to a real file
- Memory: use
BytesMutto mock a mmap, which is useful for test and in-memory storage engine - Empty: a state represents null mmap, which is helpful for drop, remove, close the
AsyncMmapFileMut. This state cannot be constructed directly.
Implementations§
Source§impl AsyncMmapFileMut
impl AsyncMmapFileMut
Sourcepub async fn create<P: AsRef<Path>>(path: P) -> Result<Self>
pub async fn create<P: AsRef<Path>>(path: P) -> Result<Self>
Create a new file and mmap this file
§Notes
The new file is zero size, so, before write, you should truncate first.
Or you can use create_with_options and set max_size field for AsyncOptions to enable directly write
without truncating.
§Examples
use fmmap::tokio::{AsyncMmapFileMut, AsyncMmapFileMutExt};
let mut file = AsyncMmapFileMut::create("tokio_async_create_test.txt").await.unwrap();
file.truncate(12).await;
file.write_all("some data...".as_bytes(), 0).unwrap();
file.flush().unwrap();Sourcepub async fn create_with_options<P: AsRef<Path>>(
path: P,
opts: AsyncOptions,
) -> Result<Self>
pub async fn create_with_options<P: AsRef<Path>>( path: P, opts: AsyncOptions, ) -> Result<Self>
Create a new file and mmap this file with AsyncOptions
§Example
use fmmap::tokio::{AsyncOptions, AsyncMmapFileMut, AsyncMmapFileMutExt};
let opts = AsyncOptions::new()
// truncate to 100
.max_size(100);
let mut file = AsyncMmapFileMut::create_with_options("tokio_async_create_with_options_test.txt", opts).await.unwrap();
file.write_all("some data...".as_bytes(), 0).unwrap();
file.flush().unwrap();Sourcepub async fn open<P: AsRef<Path>>(path: P) -> Result<Self>
pub async fn open<P: AsRef<Path>>(path: P) -> Result<Self>
Open or Create(if not exists) a file and mmap this file.
§Notes
If the file does not exist, then the new file will be open in zero size, so before do write, you should truncate first.
Or you can use open_with_options and set max_size field for AsyncOptions to enable directly write
without truncating.
§Examples
File already exists
use fmmap::tokio::{AsyncMmapFileMut, AsyncMmapFileExt, AsyncMmapFileMutExt};
// mmap the file
let mut file = AsyncMmapFileMut::open("tokio_async_open_test.txt").await.unwrap();
let mut buf = vec![0; "some data...".len()];
file.read_exact(buf.as_mut_slice(), 0).unwrap();
assert_eq!(buf.as_slice(), "some data...".as_bytes());
// modify the file data
file.truncate("some modified data...".len() as u64).await.unwrap();
file.write_all("some modified data...".as_bytes(), 0).unwrap();
file.flush().unwrap();
drop(file);
// reopen to check content
let mut buf = vec![0; "some modified data...".len()];
let mut file = AsyncMmapFileMut::open("tokio_async_open_test.txt").await.unwrap();
file.read_exact(buf.as_mut_slice(), 0).unwrap();
assert_eq!(buf.as_slice(), "some modified data...".as_bytes());File does not exists
use fmmap::tokio::{AsyncMmapFileMut, AsyncMmapFileExt, AsyncMmapFileMutExt};
// mmap the file
let mut file = AsyncMmapFileMut::open("tokio_async_open_test.txt").await.unwrap();
file.truncate(100).await.unwrap();
file.write_all("some data...".as_bytes(), 0).unwrap();
file.flush().unwrap();
let mut buf = vec![0; "some data...".len()];
file.read_exact(buf.as_mut_slice(), 0).unwrap();
assert_eq!(buf.as_slice(), "some data...".as_bytes());
// modify the file data
file.truncate("some modified data...".len() as u64).await.unwrap();
file.write_all("some modified data...".as_bytes(), 0).unwrap();
file.flush().unwrap();
drop(file);
// reopen to check content
let mut buf = vec![0; "some modified data...".len()];
let mut file = AsyncMmapFileMut::open("tokio_async_open_test.txt").await.unwrap();
file.read_exact(buf.as_mut_slice(), 0).unwrap();
assert_eq!(buf.as_slice(), "some modified data...".as_bytes());Sourcepub async fn open_with_options<P: AsRef<Path>>(
path: P,
opts: AsyncOptions,
) -> Result<Self>
pub async fn open_with_options<P: AsRef<Path>>( path: P, opts: AsyncOptions, ) -> Result<Self>
Open or Create(if not exists) a file and mmap this file with AsyncOptions.
§Examples
File already exists
use fmmap::tokio::{AsyncMmapFileMut, AsyncMmapFileExt, AsyncMmapFileMutExt, AsyncOptions};
// mmap the file
let opts = AsyncOptions::new()
// allow read
.read(true)
// allow write
.write(true)
// allow append
.append(true)
// truncate to 100
.max_size(100)
// mmap content after the sanity text
.offset("sanity text".as_bytes().len() as u64);
let mut file = AsyncMmapFileMut::open_with_options("tokio_async_open_with_options_test.txt", opts).await.unwrap();
let mut buf = vec![0; "some data...".len()];
file.read_exact(buf.as_mut_slice(), 0).unwrap();
assert_eq!(buf.as_slice(), "some data...".as_bytes());
// modify the file data
file.truncate(("some modified data...".len() + "sanity text".len()) as u64).await.unwrap();
file.write_all("some modified data...".as_bytes(), 0).unwrap();
file.flush().unwrap();
drop(file);
// reopen to check content
let mut buf = vec![0; "some modified data...".len()];
let mut file = AsyncMmapFileMut::open("tokio_async_open_with_options_test.txt").await.unwrap();
// skip the sanity text
file.read_exact(buf.as_mut_slice(), "sanity text".as_bytes().len()).unwrap();
assert_eq!(buf.as_slice(), "some modified data...".as_bytes());File does not exists
use fmmap::tokio::{AsyncMmapFileMut, AsyncMmapFileExt, AsyncMmapFileMutExt, AsyncOptions};
// mmap the file with options
let opts = AsyncOptions::new()
// allow read
.read(true)
// allow write
.write(true)
// allow append
.append(true)
// truncate to 100
.max_size(100);
let mut file = AsyncMmapFileMut::open_with_options("tokio_async_open_with_options_test.txt", opts).await.unwrap();
file.write_all("some data...".as_bytes(), 0).unwrap();
let mut buf = vec![0; "some data...".len()];
file.read_exact(buf.as_mut_slice(), 0).unwrap();
assert_eq!(buf.as_slice(), "some data...".as_bytes());
// modify the file data
file.truncate("some modified data...".len() as u64).await.unwrap();
file.write_all("some modified data...".as_bytes(), 0).unwrap();
file.flush().unwrap();
drop(file);
// reopen to check content
let mut buf = vec![0; "some modified data...".len()];
let mut file = AsyncMmapFileMut::open("tokio_async_open_with_options_test.txt").await.unwrap();
file.read_exact(buf.as_mut_slice(), 0).unwrap();
assert_eq!(buf.as_slice(), "some modified data...".as_bytes());Sourcepub async fn open_exist<P: AsRef<Path>>(path: P) -> Result<Self>
pub async fn open_exist<P: AsRef<Path>>(path: P) -> Result<Self>
Open an existing file and mmap this file
§Examples
use fmmap::tokio::{AsyncMmapFileMut, AsyncMmapFileExt, AsyncMmapFileMutExt};
// create a temp file
let mut file = AsyncMmapFileMut::create("tokio_async_open_existing_test.txt").await.unwrap();
file.truncate(12).await.unwrap();
file.write_all("some data...".as_bytes(), 0).unwrap();
file.flush().unwrap();
drop(file);
// mmap the file
let mut file = AsyncMmapFileMut::open_exist("tokio_async_open_existing_test.txt").await.unwrap();
let mut buf = vec![0; "some data...".len()];
file.read_exact(buf.as_mut_slice(), 0).unwrap();
assert_eq!(buf.as_slice(), "some data...".as_bytes());
// modify the file data
file.truncate("some modified data...".len() as u64).await.unwrap();
file.write_all("some modified data...".as_bytes(), 0).unwrap();
file.flush().unwrap();
drop(file);
// reopen to check content
let mut buf = vec![0; "some modified data...".len()];
let mut file = AsyncMmapFileMut::open("tokio_async_open_existing_test.txt").await.unwrap();
file.read_exact(buf.as_mut_slice(), 0).unwrap();
assert_eq!(buf.as_slice(), "some modified data...".as_bytes());Sourcepub async fn open_exist_with_options<P: AsRef<Path>>(
path: P,
opts: AsyncOptions,
) -> Result<Self>
pub async fn open_exist_with_options<P: AsRef<Path>>( path: P, opts: AsyncOptions, ) -> Result<Self>
Open an existing file and mmap this file with AsyncOptions
§Examples
use fmmap::tokio::{AsyncMmapFileMut, AsyncMmapFileExt, AsyncMmapFileMutExt, AsyncOptions};
// create a temp file
let mut file = AsyncMmapFileMut::create("tokio_async_open_existing_test_with_options.txt").await.unwrap();
file.truncate(23).await.unwrap();
file.write_all("sanity text".as_bytes(), 0).unwrap();
file.write_all("some data...".as_bytes(), "sanity text".as_bytes().len()).unwrap();
file.flush().unwrap();
drop(file);
// mmap the file
let opts = AsyncOptions::new()
// truncate to 100
.max_size(100)
// mmap content after the sanity text
.offset("sanity text".as_bytes().len() as u64);
let mut file = AsyncMmapFileMut::open_exist_with_options("tokio_async_open_existing_test_with_options.txt", opts).await.unwrap();
let mut buf = vec![0; "some data...".len()];
file.read_exact(buf.as_mut_slice(), 0).unwrap();
assert_eq!(buf.as_slice(), "some data...".as_bytes());
// modify the file data
file.truncate(("some modified data...".len() + "sanity text".len()) as u64).await.unwrap();
file.write_all("some modified data...".as_bytes(), 0).unwrap();
file.flush().unwrap();
// reopen to check content, cow will not change the content.
let mut file = AsyncMmapFileMut::open("tokio_async_open_existing_test_with_options.txt").await.unwrap();
let mut buf = vec![0; "some modified data...".len()];
// skip the sanity text
// file.read_exact(buf.as_mut_slice(), "sanity text".as_bytes().len()).unwrap();
// assert_eq!(buf.as_slice(), "some modified data...".as_bytes());Sourcepub async fn open_cow<P: AsRef<Path>>(path: P) -> Result<Self>
pub async fn open_cow<P: AsRef<Path>>(path: P) -> Result<Self>
Open and mmap an existing file in copy-on-write mode(copy-on-write memory map backed by a file). Data written to the memory map will not be visible by other processes, and will not be carried through to the underlying file.
§Examples
use fmmap::tokio::{AsyncMmapFileMut, AsyncMmapFileExt, AsyncMmapFileMutExt};
// create a temp file
let mut file = AsyncMmapFileMut::create("tokio_async_open_cow_test.txt").await.unwrap();
file.truncate(12).await.unwrap();
file.write_all("some data...".as_bytes(), 0).unwrap();
file.flush().unwrap();
drop(file);
// mmap the file
let mut file = AsyncMmapFileMut::open_cow("tokio_async_open_cow_test.txt").await.unwrap();
let mut buf = vec![0; "some data...".len()];
file.read_exact(buf.as_mut_slice(), 0).unwrap();
assert_eq!(buf.as_slice(), "some data...".as_bytes());
// modify the file data
file.write_all("some data!!!".as_bytes(), 0).unwrap();
file.flush().unwrap();
// cow, change will only be seen in current caller
assert_eq!(file.as_slice(), "some data!!!".as_bytes());
drop(file);
// reopen to check content, cow will not change the content.
let mut file = AsyncMmapFileMut::open("tokio_async_open_cow_test.txt").await.unwrap();
let mut buf = vec![0; "some data...".len()];
file.read_exact(buf.as_mut_slice(), 0).unwrap();
assert_eq!(buf.as_slice(), "some data...".as_bytes());Sourcepub async fn open_cow_with_options<P: AsRef<Path>>(
path: P,
opts: AsyncOptions,
) -> Result<Self>
pub async fn open_cow_with_options<P: AsRef<Path>>( path: P, opts: AsyncOptions, ) -> Result<Self>
Open and mmap an existing file in copy-on-write mode(copy-on-write memory map backed by a file) with AsyncOptions.
Data written to the memory map will not be visible by other processes, and will not be carried through to the underlying file.
§Examples
use fmmap::tokio::{AsyncMmapFileMut, AsyncMmapFileExt, AsyncMmapFileMutExt, AsyncOptions};
use std::io::SeekFrom;
// create a temp file
let mut file = AsyncMmapFileMut::create("tokio_async_open_cow_with_options_test.txt").await.unwrap();
file.truncate(23).await.unwrap();
file.write_all("sanity text".as_bytes(), 0).unwrap();
file.write_all("some data...".as_bytes(), "sanity text".as_bytes().len()).unwrap();
file.flush().unwrap();
drop(file);
// mmap the file
let opts = AsyncOptions::new()
// mmap content after the sanity text
.offset("sanity text".as_bytes().len() as u64);
let mut file = AsyncMmapFileMut::open_cow_with_options("tokio_async_open_cow_with_options_test.txt", opts).await.unwrap();
let mut buf = vec![0; "some data...".len()];
file.read_exact(buf.as_mut_slice(), 0).unwrap();
assert_eq!(buf.as_slice(), "some data...".as_bytes());
// modify the file data
file.write_all("some data!!!".as_bytes(), 0).unwrap();
file.flush().unwrap();
// cow, change will only be seen in current caller
assert_eq!(file.as_slice(), "some data!!!".as_bytes());
drop(file);
// reopen to check content, cow will not change the content.
let mut file = AsyncMmapFileMut::open("tokio_async_open_cow_with_options_test.txt").await.unwrap();
let mut buf = vec![0; "some data...".len()];
// skip the sanity text
file.read_exact(buf.as_mut_slice(), "sanity text".as_bytes().len()).unwrap();
assert_eq!(buf.as_slice(), "some data...".as_bytes());Sourcepub fn freeze(self) -> Result<AsyncMmapFile>
pub fn freeze(self) -> Result<AsyncMmapFile>
Make the mmap file read-only.
§Notes
If remove_on_drop is set to true, then the underlying file will not be removed on drop if this function is invoked. Read more
Returns an immutable version of this memory mapped buffer. If the memory map is file-backed, the file must have been opened with read permissions.
§Errors
This method returns an error when the underlying system call fails, which can happen for a variety of reasons, such as when the file has not been opened with read permissions.
§Examples
use fmmap::tokio::{AsyncMmapFileMut, AsyncMmapFileMutExt};
let mut file = AsyncMmapFileMut::create("tokio_async_freeze_test.txt").await.unwrap();
file.truncate(12).await;
file.write_all("some data...".as_bytes(), 0).unwrap();
file.flush().unwrap();
// freeze
file.freeze().unwrap();Sourcepub fn freeze_exec(self) -> Result<AsyncMmapFile>
pub fn freeze_exec(self) -> Result<AsyncMmapFile>
Transition the memory map to be readable and executable. If the memory map is file-backed, the file must have been opened with execute permissions.
§Notes
If remove_on_drop is set to true, then the underlying file will not be removed on drop if this function is invoked. Read more
§Errors
This method returns an error when the underlying system call fails, which can happen for a variety of reasons, such as when the file has not been opened with execute permissions
§Examples
use fmmap::tokio::{AsyncMmapFileMut, AsyncMmapFileMutExt};
let mut file = AsyncMmapFileMut::create("tokio_async_freeze_exec_test.txt").await.unwrap();
file.truncate(12).await;
file.write_all("some data...".as_bytes(), 0).unwrap();
file.flush().unwrap();
// freeze_exec
file.freeze_exec().unwrap();Sourcepub fn get_remove_on_drop(&self) -> bool
pub fn get_remove_on_drop(&self) -> bool
Returns whether remove the underlying file on drop.
Sourcepub fn set_remove_on_drop(&mut self, val: bool)
pub fn set_remove_on_drop(&mut self, val: bool)
Whether remove the underlying file on drop. Default is false.
§Notes
If invoke AsyncMmapFileMut::freeze, then the file will
not be removed even though the field remove_on_drop is true.
Source§impl AsyncMmapFileMut
impl AsyncMmapFileMut
Sourcepub fn memory_with_capacity<P: AsRef<Path>>(path: P, cap: usize) -> Self
pub fn memory_with_capacity<P: AsRef<Path>>(path: P, cap: usize) -> Self
Sourcepub fn memory_from_string<P: AsRef<Path>>(path: P, src: String) -> Self
pub fn memory_from_string<P: AsRef<Path>>(path: P, src: String) -> Self
Sourcepub fn memory_from_str<P: AsRef<Path>>(path: P, src: &'static str) -> Self
pub fn memory_from_str<P: AsRef<Path>>(path: P, src: &'static str) -> Self
Trait Implementations§
Source§impl AsyncMmapFileExt for AsyncMmapFileMut
impl AsyncMmapFileExt for AsyncMmapFileMut
Source§fn lock_exclusive(&self) -> Result<()>
fn lock_exclusive(&self) -> Result<()>
Source§fn try_lock_exclusive(&self) -> Result<()>
fn try_lock_exclusive(&self) -> Result<()>
Source§fn slice(&self, offset: usize, sz: usize) -> &[u8] ⓘ
fn slice(&self, offset: usize, sz: usize) -> &[u8] ⓘ
Source§fn bytes(&self, offset: usize, sz: usize) -> Result<&[u8]>
fn bytes(&self, offset: usize, sz: usize) -> Result<&[u8]>
Source§fn path_lossy(&self) -> Cow<'_, str>
fn path_lossy(&self) -> Cow<'_, str>
Source§fn path_string(&self) -> String
fn path_string(&self) -> String
Source§fn copy_range_to_vec(&self, offset: usize, len: usize) -> Vec<u8> ⓘ
fn copy_range_to_vec(&self, offset: usize, len: usize) -> Vec<u8> ⓘ
Source§fn write_all_to_new_file<P: AsRef<Path> + Send + Sync>(
&self,
new_file_path: P,
) -> impl Future<Output = Result<()>> + Send
fn write_all_to_new_file<P: AsRef<Path> + Send + Sync>( &self, new_file_path: P, ) -> impl Future<Output = Result<()>> + Send
Source§fn write_range_to_new_file<P: AsRef<Path> + Send + Sync>(
&self,
new_file_path: P,
offset: usize,
len: usize,
) -> impl Future<Output = Result<()>> + Send
fn write_range_to_new_file<P: AsRef<Path> + Send + Sync>( &self, new_file_path: P, offset: usize, len: usize, ) -> impl Future<Output = Result<()>> + Send
Source§fn reader(&self, offset: usize) -> Result<AsyncMmapFileReader<'_>>
fn reader(&self, offset: usize) -> Result<AsyncMmapFileReader<'_>>
AsyncMmapFileReader which helps read data from mmap like a normal File. Read moreSource§fn range_reader(
&self,
offset: usize,
len: usize,
) -> Result<AsyncMmapFileReader<'_>>
fn range_reader( &self, offset: usize, len: usize, ) -> Result<AsyncMmapFileReader<'_>>
AsyncMmapFileReader base on the given offset and len, which helps read data from mmap like a normal File. Read moreSource§fn read(&self, dst: &mut [u8], offset: usize) -> usize
fn read(&self, dst: &mut [u8], offset: usize) -> usize
Source§fn read_exact(&self, dst: &mut [u8], offset: usize) -> Result<()>
fn read_exact(&self, dst: &mut [u8], offset: usize) -> Result<()>
Source§fn read_i16(&self, offset: usize) -> Result<i16>
fn read_i16(&self, offset: usize) -> Result<i16>
Source§fn read_i16_le(&self, offset: usize) -> Result<i16>
fn read_i16_le(&self, offset: usize) -> Result<i16>
Source§fn read_isize(&self, offset: usize) -> Result<isize>
fn read_isize(&self, offset: usize) -> Result<isize>
Source§fn read_isize_le(&self, offset: usize) -> Result<isize>
fn read_isize_le(&self, offset: usize) -> Result<isize>
Source§fn read_i32(&self, offset: usize) -> Result<i32>
fn read_i32(&self, offset: usize) -> Result<i32>
Source§fn read_i32_le(&self, offset: usize) -> Result<i32>
fn read_i32_le(&self, offset: usize) -> Result<i32>
Source§fn read_i64(&self, offset: usize) -> Result<i64>
fn read_i64(&self, offset: usize) -> Result<i64>
Source§fn read_i64_le(&self, offset: usize) -> Result<i64>
fn read_i64_le(&self, offset: usize) -> Result<i64>
Source§fn read_i128(&self, offset: usize) -> Result<i128>
fn read_i128(&self, offset: usize) -> Result<i128>
Source§fn read_i128_le(&self, offset: usize) -> Result<i128>
fn read_i128_le(&self, offset: usize) -> Result<i128>
Source§fn read_u16(&self, offset: usize) -> Result<u16>
fn read_u16(&self, offset: usize) -> Result<u16>
Source§fn read_u16_le(&self, offset: usize) -> Result<u16>
fn read_u16_le(&self, offset: usize) -> Result<u16>
Source§fn read_usize(&self, offset: usize) -> Result<usize>
fn read_usize(&self, offset: usize) -> Result<usize>
Source§fn read_usize_le(&self, offset: usize) -> Result<usize>
fn read_usize_le(&self, offset: usize) -> Result<usize>
Source§fn read_u32(&self, offset: usize) -> Result<u32>
fn read_u32(&self, offset: usize) -> Result<u32>
Source§fn read_u32_le(&self, offset: usize) -> Result<u32>
fn read_u32_le(&self, offset: usize) -> Result<u32>
Source§fn read_u64(&self, offset: usize) -> Result<u64>
fn read_u64(&self, offset: usize) -> Result<u64>
Source§fn read_u64_le(&self, offset: usize) -> Result<u64>
fn read_u64_le(&self, offset: usize) -> Result<u64>
Source§fn read_u128(&self, offset: usize) -> Result<u128>
fn read_u128(&self, offset: usize) -> Result<u128>
Source§fn read_u128_le(&self, offset: usize) -> Result<u128>
fn read_u128_le(&self, offset: usize) -> Result<u128>
Source§fn read_f32(&self, offset: usize) -> Result<f32>
fn read_f32(&self, offset: usize) -> Result<f32>
Source§fn read_f32_le(&self, offset: usize) -> Result<f32>
fn read_f32_le(&self, offset: usize) -> Result<f32>
Source§impl AsyncMmapFileMutExt for AsyncMmapFileMut
impl AsyncMmapFileMutExt for AsyncMmapFileMut
Source§async fn drop_remove(self) -> Result<()>
async fn drop_remove(self) -> Result<()>
Remove the underlying file
§Example
use fmmap::tokio::{AsyncMmapFileMut, AsyncMmapFileMutExt};
use tokio::fs::File;
let mut file = AsyncMmapFileMut::create("tokio_async_remove_test.txt").await.unwrap();
file.truncate(12).await;
file.write_all("some data...".as_bytes(), 0).unwrap();
file.flush().unwrap();
file.drop_remove().await.unwrap();
let err = File::open("tokio_async_remove_test.txt").await;
assert_eq!(err.unwrap_err().kind(), std::io::ErrorKind::NotFound);Source§async fn close_with_truncate(self, max_sz: i64) -> Result<()>
async fn close_with_truncate(self, max_sz: i64) -> Result<()>
Close and truncate the underlying file
§Examples
use fmmap::{MetaDataExt,tokio::{AsyncMmapFileMut, AsyncMmapFileExt, AsyncMmapFileMutExt}};
let mut file = AsyncMmapFileMut::create("tokio_async_close_with_truncate_test.txt").await.unwrap();
file.truncate(100).await;
file.write_all("some data...".as_bytes(), 0).unwrap();
file.flush().unwrap();
file.close_with_truncate(50).await.unwrap();
let file = AsyncMmapFileMut::open("tokio_async_close_with_truncate_test.txt").await.unwrap();
let meta = file.metadata().await.unwrap();
assert_eq!(meta.len(), 50);Source§fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
Source§fn flush(&self) -> Result<()>
fn flush(&self) -> Result<()>
Source§fn flush_async(&self) -> Result<()>
fn flush_async(&self) -> Result<()>
Source§fn flush_range(&self, offset: usize, len: usize) -> Result<()>
fn flush_range(&self, offset: usize, len: usize) -> Result<()>
Source§fn flush_async_range(&self, offset: usize, len: usize) -> Result<()>
fn flush_async_range(&self, offset: usize, len: usize) -> Result<()>
Source§async fn truncate(&mut self, max_sz: u64) -> Result<()>
async fn truncate(&mut self, max_sz: u64) -> Result<()>
max_size, which will lead to
do re-mmap and sync_dir if the inner is a real file.Source§fn slice_mut(&mut self, offset: usize, sz: usize) -> &mut [u8] ⓘ
fn slice_mut(&mut self, offset: usize, sz: usize) -> &mut [u8] ⓘ
Source§fn bytes_mut(&mut self, offset: usize, sz: usize) -> Result<&mut [u8]>
fn bytes_mut(&mut self, offset: usize, sz: usize) -> Result<&mut [u8]>
Source§fn zero_range(&mut self, start: usize, end: usize)
fn zero_range(&mut self, start: usize, end: usize)
Source§fn writer(&mut self, offset: usize) -> Result<AsyncMmapFileWriter<'_>>
fn writer(&mut self, offset: usize) -> Result<AsyncMmapFileWriter<'_>>
AsyncMmapFileWriter base on the given offset, which helps read or write data from mmap like a normal File. Read moreSource§fn range_writer(
&mut self,
offset: usize,
len: usize,
) -> Result<AsyncMmapFileWriter<'_>>
fn range_writer( &mut self, offset: usize, len: usize, ) -> Result<AsyncMmapFileWriter<'_>>
AsyncMmapFileWriter base on the given offset and len, which helps read or write data from mmap like a normal File. Read moreSource§fn write(&mut self, src: &[u8], offset: usize) -> usize
fn write(&mut self, src: &[u8], offset: usize) -> usize
Source§fn write_all(&mut self, src: &[u8], offset: usize) -> Result<()>
fn write_all(&mut self, src: &[u8], offset: usize) -> Result<()>
src to the mmap from the offset.