Skip to main content

DtactFile

Struct DtactFile 

Source
pub struct DtactFile { /* private fields */ }
Expand description

An open file whose ops are submitted as real io_uring SQEs.

Implementations§

Source§

impl DtactFile

Source

pub async fn open(path: impl Into<PathBuf>) -> Result<Self>

Open an existing file for reading via a ring-submitted Openat.

§Errors

Returns an io::Error if the underlying Openat completion reports one — most commonly NotFound if path doesn’t exist, or PermissionDenied if it exists but isn’t readable.

Source

pub async fn create(path: impl Into<PathBuf>) -> Result<Self>

Create (truncating if it already exists) a file for reading and writing via a ring-submitted Openat.

§Errors

Returns an io::Error if the underlying Openat completion reports one, e.g. PermissionDenied if the containing directory isn’t writable.

Source

pub async fn open_with( path: impl Into<PathBuf>, opts: OpenOptions, ) -> Result<Self>

Generic open honoring an arbitrary std::fs::OpenOptions. See the doc comment inline below for why this falls back to a synchronous open() rather than a pure-uring one.

§Errors

Returns whatever std::fs::OpenOptions::open returns for path with opts applied (e.g. NotFound, PermissionDenied, AlreadyExists depending on which OpenOptions flags are set).

Source

pub async fn read(&self, buf: Vec<u8>) -> Result<(usize, Vec<u8>)>

Read at the file’s shared cursor, advancing it by the number of bytes actually read. buf is handed back (resized to what was filled) so the caller can reuse its allocation.

§Errors

Returns an io::Error if the underlying Read completion reports one; a short read (including 0 at EOF) is a normal Ok, not an error.

Source

pub async fn write(&self, buf: Vec<u8>) -> Result<(usize, Vec<u8>)>

Write at the file’s shared cursor, advancing it by the number of bytes actually written. buf is handed back so the caller can reuse its allocation.

§Errors

Returns an io::Error if the underlying Write completion reports one (e.g. disk full, or the fd was closed concurrently).

Source

pub async fn read_at( &self, buf: Vec<u8>, offset: u64, ) -> Result<(usize, Vec<u8>)>

Positional read: submits its own SQE with an explicit offset, so concurrent read_at/write_at calls on the same handle are safe (no shared cursor involved).

§Errors

Same as Self::read.

Source

pub async fn write_at( &self, buf: Vec<u8>, offset: u64, ) -> Result<(usize, Vec<u8>)>

Positional write: submits its own SQE with an explicit offset, so concurrent read_at/write_at calls on the same handle are safe.

§Errors

Same as Self::write.

Source

pub async fn sync_all(&self) -> Result<()>

Flush all buffered writes to disk via a ring-submitted Fsync.

§Errors

Returns an io::Error if the underlying Fsync completion reports one (e.g. the underlying device was removed).

Source

pub async fn metadata(&self) -> Result<Metadata>

File metadata (size, timestamps, permissions, …).

§Errors

Returns an io::Error if the underlying fstat fails (e.g. the fd was closed concurrently).

Source

pub async fn close(self) -> Result<()>

Explicitly close this file via a ring-submitted Close, rather than waiting for Drop (which closes synchronously instead).

§Errors

Returns an io::Error if the underlying Close completion reports one.

Trait Implementations§

Source§

impl Drop for DtactFile

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for DtactFile

Source§

impl Sync for DtactFile

Auto Trait Implementations§

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.