#[repr(transparent)]pub struct AioWrite<'a> { /* private fields */ }
Expand description
Asynchronously writes from a buffer to a file descriptor
References
Examples
const WBUF: &[u8] = b"abcdef123456";
let mut f = tempfile().unwrap();
let mut aiow = Box::pin(
AioWrite::new(
f.as_raw_fd(),
2, //offset
WBUF,
0, //priority
SigevNotify::SigevNone
)
);
aiow.as_mut().submit().unwrap();
while (aiow.as_mut().error() == Err(Errno::EINPROGRESS)) {
thread::sleep(time::Duration::from_millis(10));
}
assert_eq!(aiow.as_mut().aio_return().unwrap(), WBUF.len());
Implementations
sourceimpl<'a> AioWrite<'a>
impl<'a> AioWrite<'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 [u8],
prio: i32,
sigev_notify: SigevNotify
) -> Self
pub fn new(
fd: RawFd,
offs: off_t,
buf: &'a [u8],
prio: i32,
sigev_notify: SigevNotify
) -> Self
Construct a new AioWrite
.
Arguments
fd
: File descriptor to write tooffs
: File offsetbuf
: A memory buffer. It must outlive theAioWrite
.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 AioWrite<'a>
impl<'a> Aio for AioWrite<'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 AioWrite<'a>
impl<'a> Send for AioWrite<'a>
impl<'a> Sync for AioWrite<'a>
impl<'a> !Unpin for AioWrite<'a>
impl<'a> UnwindSafe for AioWrite<'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