Enum cros_async::io_source::IoSource
source · pub enum IoSource<F: AsRawDescriptor> {
Uring(UringSource<F>),
Epoll(PollSource<F>),
Tokio(TokioSource<F>),
}
Expand description
Associates an IO object F
with cros_async’s runtime and exposes an API to perform async IO on
that object’s descriptor.
Variants§
Implementations§
source§impl<F: AsRawDescriptor> IoSource<F>
impl<F: AsRawDescriptor> IoSource<F>
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 at file_offset
and fills the given vec
.
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 wait_readable(&self) -> AsyncResult<()>
pub async fn wait_readable(&self) -> AsyncResult<()>
Waits for the object to be readable.
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
at the given offsets to the file starting at file_offset
.
sourcepub async fn punch_hole(&self, file_offset: u64, len: u64) -> AsyncResult<()>
pub async fn punch_hole(&self, file_offset: u64, len: u64) -> AsyncResult<()>
Deallocates the given range of a file.
sourcepub async fn write_zeroes_at(
&self,
file_offset: u64,
len: u64
) -> AsyncResult<()>
pub async fn write_zeroes_at( &self, file_offset: u64, len: u64 ) -> AsyncResult<()>
Fills the given range with zeroes.
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, avoiding updating extra metadata. Note that an implementation may simply implement fsync for fdatasync.
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 mutable ref to the underlying IO source.