@@ -84,6 +84,11 @@ pub struct AioCb<'a> {
84
84
}
85
85
86
86
impl < ' a > AioCb < ' a > {
87
+ /// Returns the underlying file descriptor associated with the `AioCb`
88
+ pub fn fd ( & self ) -> RawFd {
89
+ self . aiocb . aio_fildes
90
+ }
91
+
87
92
/// Constructs a new `AioCb` with no associated buffer.
88
93
///
89
94
/// The resulting `AioCb` structure is suitable for use with `AioCb::fsync`.
@@ -239,6 +244,38 @@ impl<'a> AioCb<'a> {
239
244
} )
240
245
}
241
246
247
+ /// Returns the `aiocb`'s `LioOpcode` field
248
+ ///
249
+ /// If the value cannot be represented as an `LioOpcode`, returns `None`
250
+ /// instead.
251
+ pub fn lio_opcode ( & self ) -> Option < LioOpcode > {
252
+ match self . aiocb . aio_lio_opcode {
253
+ libc:: LIO_READ => Some ( LioOpcode :: LIO_READ ) ,
254
+ libc:: LIO_WRITE => Some ( LioOpcode :: LIO_WRITE ) ,
255
+ libc:: LIO_NOP => Some ( LioOpcode :: LIO_NOP ) ,
256
+ _ => None
257
+ }
258
+ }
259
+
260
+ /// Returns the requested length of the aio operation in bytes
261
+ ///
262
+ /// This method returns the *requested* length of the operation. To get the
263
+ /// number of bytes actually read or written by a completed operation, use
264
+ /// `aio_return` instead.
265
+ pub fn nbytes ( & self ) -> usize {
266
+ self . aiocb . aio_nbytes
267
+ }
268
+
269
+ /// Returns the file offset stored in the `AioCb`
270
+ pub fn offset ( & self ) -> off_t {
271
+ self . aiocb . aio_offset
272
+ }
273
+
274
+ /// Returns the priority of the `AioCb`
275
+ pub fn priority ( & self ) -> libc:: c_int {
276
+ self . aiocb . aio_reqprio
277
+ }
278
+
242
279
/// Asynchronously reads from a file descriptor into a buffer
243
280
pub fn read ( & mut self ) -> Result < ( ) > {
244
281
assert ! ( self . mutable, "Can't read into an immutable buffer" ) ;
@@ -250,6 +287,11 @@ impl<'a> AioCb<'a> {
250
287
} )
251
288
}
252
289
290
+ /// Returns the `SigEvent` stored in the `AioCb`
291
+ pub fn sigevent ( & self ) -> SigEvent {
292
+ SigEvent :: from ( & self . aiocb . aio_sigevent )
293
+ }
294
+
253
295
/// Retrieve return status of an asynchronous operation. Should only be
254
296
/// called once for each `AioCb`, after `AioCb::error` indicates that it has
255
297
/// completed. The result is the same as for `read`, `write`, of `fsync`.
0 commit comments