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§

source§

impl<'a> AioReadv<'a>

source

pub fn iovlen(&self) -> usize

Returns the number of buffers the operation will read into.

source

pub fn new( fd: RawFd, offs: off_t, bufs: &mut [IoSliceMut<'a>], prio: i32, sigev_notify: SigevNotify ) -> Self

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.
source

pub fn offset(&self) -> off_t

Returns the file offset of the operation.

Trait Implementations§

source§

impl<'a> Aio for AioReadv<'a>

§

type Output = usize

The return type of Aio::aio_return.
source§

fn cancel(self: Pin<&mut Self>) -> Result<AioCancelStat>

Cancels an outstanding AIO request. Read more
source§

fn error(self: Pin<&mut Self>) -> Result<()>

Retrieve error status of an asynchronous operation. Read more
source§

fn fd(&self) -> RawFd

Returns the underlying file descriptor associated with the operation.
source§

fn in_progress(&self) -> bool

Does this operation currently have any in-kernel state? Read more
source§

fn priority(&self) -> i32

Returns the priority of the AioCb
source§

fn set_sigev_notify(&mut self, sev: SigevNotify)

Update the notification settings for an existing AIO operation that has not yet been submitted.
source§

fn sigevent(&self) -> SigEvent

Returns the SigEvent that will be used for notification.
source§

fn aio_return(self: Pin<&mut Self>) -> Result<<Self as Aio>::Output>

Retrieve return status of an asynchronous operation. Read more
source§

fn submit(self: Pin<&mut Self>) -> Result<()>

Actually start the I/O operation. Read more
source§

impl<'a> AsMut<aiocb> for AioReadv<'a>

source§

fn as_mut(&mut self) -> &mut aiocb

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<'a> AsRef<aiocb> for AioReadv<'a>

source§

fn as_ref(&self) -> &aiocb

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<'a> Debug for AioReadv<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for AioReadv<'a>

§

impl<'a> Send for AioReadv<'a>

§

impl<'a> Sync for AioReadv<'a>

§

impl<'a> !Unpin for AioReadv<'a>

§

impl<'a> UnwindSafe for AioReadv<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.