Struct nix::sys::aio::AioReadv

source ·
#[repr(transparent)]
pub struct AioReadv<'a> { /* private fields */ }
Available on crate feature aio only.
Expand description

Asynchronously reads from a file descriptor into a scatter/gather list of buffers.

References

aio_readv

Examples

const INITIAL: &[u8] = b"abcdef123456";
let mut rbuf0 = vec![0; 4];
let mut rbuf1 = vec![0; 2];
let expected_len = rbuf0.len() + rbuf1.len();
let mut rbufs = [IoSliceMut::new(&mut rbuf0), IoSliceMut::new(&mut rbuf1)];
let mut f = tempfile().unwrap();
f.write_all(INITIAL).unwrap();
{
   let mut aior = Box::pin(
       AioReadv::new(
           f.as_raw_fd(),
           2,   //offset
           &mut rbufs,
           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(), expected_len);
}
assert_eq!(rbuf0, b"cdef");
assert_eq!(rbuf1, b"12");

Implementations§

Returns the number of buffers the operation will read into.

Create a new AioReadv, placing the data in a list of mutable slices.

Arguments
  • fd: File descriptor to read from
  • offs: File offset
  • bufs: A scatter/gather list of memory buffers. They must outlive the AioReadv.
  • prio: If POSIX Prioritized IO is supported, then the operation will be prioritized at the process’s priority level minus prio
  • sigev_notify: Determines how you will be notified of event completion.

Returns the file offset of the operation.

Trait Implementations§

The return type of Aio::aio_return.
Cancels an outstanding AIO request. Read more
Retrieve error status of an asynchronous operation. Read more
Returns the underlying file descriptor associated with the operation.
Does this operation currently have any in-kernel state? Read more
Returns the priority of the AioCb
Update the notification settings for an existing AIO operation that has not yet been submitted.
Returns the SigEvent that will be used for notification.
Retrieve return status of an asynchronous operation. Read more
Actually start the I/O operation. Read more
Converts this type into a mutable reference of the (usually inferred) input type.
Converts this type into a shared reference of the (usually inferred) input type.
Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.