Struct nix::sys::aio::AioRead

source ·
pub struct AioRead<'a> { /* private fields */ }
Expand description

Asynchronously reads from a file descriptor into a buffer

§References

aio_read

§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_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§

source§

impl<'a> AioRead<'a>

source

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.

source

pub fn new( fd: BorrowedFd<'a>, 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 from
  • offs: File offset
  • buf: A memory buffer. It must outlive the AioRead.
  • 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 AioRead<'a>

source§

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) -> BorrowedFd<'a>

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 AioRead<'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 AioRead<'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 AioRead<'a>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for AioRead<'a>

§

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§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

source§

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 T
where U: TryFrom<T>,

source§

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.