Struct cros_async::sys::unix::uring_source::UringSource
source · pub struct UringSource<F: AsRawDescriptor> {
registered_source: RegisteredSource,
source: F,
}
Expand description
UringSource
wraps FD backed IO sources for use with io_uring. It is a thin wrapper around
registering an IO source with the uring that provides an IoSource
implementation.
Fields§
§registered_source: RegisteredSource
§source: F
Implementations§
source§impl<F: AsRawDescriptor> UringSource<F>
impl<F: AsRawDescriptor> UringSource<F>
sourcepub fn new(
io_source: F,
ex: &Arc<RawExecutor<UringReactor>>
) -> Result<UringSource<F>>
pub fn new(
io_source: F,
ex: &Arc<RawExecutor<UringReactor>>
) -> Result<UringSource<F>>
Creates a new UringSource
that wraps the given io_source
object.
sourcepub async fn read_to_vec(
&self,
file_offset: Option<u64>,
vec: Vec<u8>
) -> AsyncResult<(usize, Vec<u8>)>
pub async fn read_to_vec(
&self,
file_offset: Option<u64>,
vec: Vec<u8>
) -> AsyncResult<(usize, Vec<u8>)>
Reads from the iosource at file_offset
and fill the given vec
.
sourcepub async fn wait_readable(&self) -> AsyncResult<()>
pub async fn wait_readable(&self) -> AsyncResult<()>
Wait for the FD of self
to be readable.
sourcepub async fn read_to_mem(
&self,
file_offset: Option<u64>,
mem: Arc<dyn BackingMemory + Send + Sync>,
mem_offsets: impl IntoIterator<Item = MemRegion>
) -> AsyncResult<usize>
pub async fn read_to_mem(
&self,
file_offset: Option<u64>,
mem: Arc<dyn BackingMemory + Send + Sync>,
mem_offsets: impl IntoIterator<Item = MemRegion>
) -> AsyncResult<usize>
Reads to the given mem
at the given offsets from the file starting at file_offset
.
sourcepub async fn write_from_vec(
&self,
file_offset: Option<u64>,
vec: Vec<u8>
) -> AsyncResult<(usize, Vec<u8>)>
pub async fn write_from_vec(
&self,
file_offset: Option<u64>,
vec: Vec<u8>
) -> AsyncResult<(usize, Vec<u8>)>
Writes from the given vec
to the file starting at file_offset
.
sourcepub async fn write_from_mem(
&self,
file_offset: Option<u64>,
mem: Arc<dyn BackingMemory + Send + Sync>,
mem_offsets: impl IntoIterator<Item = MemRegion>
) -> AsyncResult<usize>
pub async fn write_from_mem(
&self,
file_offset: Option<u64>,
mem: Arc<dyn BackingMemory + Send + Sync>,
mem_offsets: impl IntoIterator<Item = MemRegion>
) -> AsyncResult<usize>
Writes from the given mem
from the given offsets to the file starting at file_offset
.
sourcepub async fn fallocate(
&self,
file_offset: u64,
len: u64,
mode: AllocateMode
) -> AsyncResult<()>
pub async fn fallocate(
&self,
file_offset: u64,
len: u64,
mode: AllocateMode
) -> AsyncResult<()>
See fallocate(2)
. Note this op is synchronous when using the Polled backend.
sourcepub async fn fsync(&self) -> AsyncResult<()>
pub async fn fsync(&self) -> AsyncResult<()>
Sync all completed write operations to the backing storage.
sourcepub async fn fdatasync(&self) -> AsyncResult<()>
pub async fn fdatasync(&self) -> AsyncResult<()>
Sync all data of completed write operations to the backing storage. Currently, the implementation is equivalent to fsync.
sourcepub fn into_source(self) -> F
pub fn into_source(self) -> F
Yields the underlying IO source.
sourcepub fn as_source_mut(&mut self) -> &mut F
pub fn as_source_mut(&mut self) -> &mut F
Provides a ref to the underlying IO source.