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

source

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.

source

pub unsafe fn get_mmap_raw_ptr(&self, offset: u64) -> *const u8

source

pub unsafe fn get_mmap_raw_mut_ptr(&self, offset: u64) -> *mut u8

source

pub async fn write_at_with_delayed_sync(&self, writes: Vec<WriteRequest>)

source

pub async fn start_delayed_data_sync_background_loop(&self)

source

pub async fn sync_data(&self)

Trait Implementations§

source§

impl Clone for SeekableAsyncFile

source§

fn clone(&self) -> SeekableAsyncFile

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Off64AsyncRead<'a, Vec<u8, Global>> for SeekableAsyncFile

source§

fn read_at<'life0, 'async_trait>( &'life0 self, offset: u64, len: u64 ) -> Pin<Box<dyn Future<Output = Vec<u8>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

impl Off64AsyncWrite<Vec<u8, Global>> for SeekableAsyncFile

source§

fn write_at<'life0, 'async_trait>( &'life0 self, offset: u64, data: Vec<u8> ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

impl<'a> Off64Read<'a, Vec<u8, Global>> for SeekableAsyncFile

source§

fn read_at(&self, offset: u64, len: u64) -> Vec<u8>

source§

impl<'a> Off64Write<Vec<u8, Global>> for SeekableAsyncFile

source§

fn write_at<'v>(&self, offset: u64, data: Vec<u8>)

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.