#[repr(transparent)]pub struct AioRead<'a> { /* private fields */ }
Expand description
Asynchronously reads from a file descriptor into a buffer
References
Examples
const INITIAL: &[u8] = b"abcdef123456";
const LEN: usize = 4;
let mut rbuf = vec![0; LEN];
let mut f = tempfile().unwrap();
f.write_all(INITIAL).unwrap();
{
let mut aior = Box::pin(
AioRead::new(
f.as_raw_fd(),
2, //offset
&mut rbuf,
0, //priority
SigevNotify::SigevNone
)
);
aior.as_mut().submit().unwrap();
while (aior.as_mut().error() == Err(Errno::EINPROGRESS)) {
thread::sleep(time::Duration::from_millis(10));
}
assert_eq!(aior.as_mut().aio_return().unwrap(), LEN);
}
assert_eq!(rbuf, b"cdef");
Implementations
sourceimpl<'a> AioRead<'a>
impl<'a> AioRead<'a>
sourcepub fn nbytes(&self) -> usize
pub fn nbytes(&self) -> usize
Returns the requested length of the aio operation in bytes
This method returns the requested length of the operation. To get the
number of bytes actually read or written by a completed operation, use
aio_return
instead.
sourcepub fn new(
fd: RawFd,
offs: off_t,
buf: &'a mut [u8],
prio: i32,
sigev_notify: SigevNotify
) -> Self
pub fn new(
fd: RawFd,
offs: off_t,
buf: &'a mut [u8],
prio: i32,
sigev_notify: SigevNotify
) -> Self
Create a new AioRead
, placing the data in a mutable slice.
Arguments
fd
: File descriptor to read fromoffs
: File offsetbuf
: A memory buffer. It must outlive theAioRead
.prio
: If POSIX Prioritized IO is supported, then the operation will be prioritized at the process’s priority level minusprio
sigev_notify
: Determines how you will be notified of event completion.
Trait Implementations
sourceimpl<'a> Aio for AioRead<'a>
impl<'a> Aio for AioRead<'a>
type Output = usize
type Output = usize
The return type of
Aio::aio_return
.sourcefn cancel(self: Pin<&mut Self>) -> Result<AioCancelStat>
fn cancel(self: Pin<&mut Self>) -> Result<AioCancelStat>
Cancels an outstanding AIO request. Read more
sourcefn error(self: Pin<&mut Self>) -> Result<()>
fn error(self: Pin<&mut Self>) -> Result<()>
Retrieve error status of an asynchronous operation. Read more
sourcefn in_progress(&self) -> bool
fn in_progress(&self) -> bool
Does this operation currently have any in-kernel state? Read more
sourcefn set_sigev_notify(&mut self, sev: SigevNotify)
fn set_sigev_notify(&mut self, sev: SigevNotify)
Update the notification settings for an existing AIO operation that has
not yet been submitted. Read more
Auto Trait Implementations
impl<'a> RefUnwindSafe for AioRead<'a>
impl<'a> Send for AioRead<'a>
impl<'a> Sync for AioRead<'a>
impl<'a> !Unpin for AioRead<'a>
impl<'a> UnwindSafe for AioRead<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more