FileIO

Struct FileIO 

Source
pub struct FileIO { /* 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 FileIO

Source

pub async fn open(path: &Path, 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.

Trait Implementations§

Source§

impl ISyncIO for FileIO

Source§

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

Source§

fn write_at_sync(&self, offset: u64, data: &[u8])

Source§

fn sync_data_sync(&self)

Auto Trait Implementations§

§

impl Freeze for FileIO

§

impl RefUnwindSafe for FileIO

§

impl Send for FileIO

§

impl Sync for FileIO

§

impl Unpin for FileIO

§

impl UnwindSafe for FileIO

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.