pub struct SeekableAsyncFile { /* private fields */ }
Expand description
A File
-like value that can perform async read_at
and write_at
for I/O at specific offsets without mutating any state (i.e. is thread safe). Metrics are collected, and syncs can be delayed for write batching opportunities as a performance optimisation.
Implementations§
Source§impl SeekableAsyncFile
impl SeekableAsyncFile
Sourcepub async fn open(
path: &Path,
size: u64,
metrics: Arc<SeekableAsyncFileMetrics>,
sync_delay: Duration,
flags: i32,
) -> Self
pub async fn open( path: &Path, size: u64, metrics: Arc<SeekableAsyncFileMetrics>, sync_delay: Duration, flags: i32, ) -> Self
Open a file descriptor in read and write modes, creating it if it doesn’t exist. If it already exists, the contents won’t be truncated.
If the mmap feature is being used, to save a stat
call, the size must be provided. This also allows opening non-standard files which may have a size of zero (e.g. block devices). A different size value also allows only using a portion of the beginning of the file.
The io_direct
and io_dsync
parameters set the O_DIRECT
and O_DSYNC
flags, respectively. Unless you need those flags, provide false
.
Make sure to execute start_delayed_data_sync_background_loop
in the background after this call.
pub unsafe fn get_mmap_raw_ptr(&self, offset: u64) -> *const u8
pub unsafe fn get_mmap_raw_mut_ptr(&self, offset: u64) -> *mut u8
pub async fn read_at(&self, offset: u64, len: u64) -> Vec<u8> ⓘ
pub fn read_at_sync(&self, offset: u64, len: u64) -> Vec<u8> ⓘ
pub async fn write_at<D: AsRef<[u8]> + Send + 'static>( &self, offset: u64, data: D, )
pub fn write_at_sync<D: AsRef<[u8]> + Send + 'static>( &self, offset: u64, data: D, )
pub async fn write_at_with_delayed_sync<D: AsRef<[u8]> + Send + 'static>( &self, writes: impl IntoIterator<Item = WriteRequest<D>>, )
pub async fn start_delayed_data_sync_background_loop(&self)
pub async fn sync_data(&self)
Trait Implementations§
Source§impl Clone for SeekableAsyncFile
impl Clone for SeekableAsyncFile
Source§fn clone(&self) -> SeekableAsyncFile
fn clone(&self) -> SeekableAsyncFile
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more