pub struct DtactFile { /* private fields */ }Expand description
An open file whose ops are submitted as real io_uring SQEs.
Implementations§
Source§impl DtactFile
impl DtactFile
Sourcepub async fn open(path: impl Into<PathBuf>) -> Result<Self>
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.
Sourcepub async fn create(path: impl Into<PathBuf>) -> Result<Self>
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.
Sourcepub async fn open_with(
path: impl Into<PathBuf>,
opts: OpenOptions,
) -> Result<Self>
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).
Sourcepub async fn read(&self, buf: Vec<u8>) -> Result<(usize, Vec<u8>)>
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.
Sourcepub async fn write(&self, buf: Vec<u8>) -> Result<(usize, Vec<u8>)>
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).
Sourcepub async fn read_at(
&self,
buf: Vec<u8>,
offset: u64,
) -> Result<(usize, Vec<u8>)>
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.
Sourcepub async fn write_at(
&self,
buf: Vec<u8>,
offset: u64,
) -> Result<(usize, Vec<u8>)>
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.
Sourcepub async fn sync_all(&self) -> Result<()>
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).