3 //! Note that this should stay small, otherwise we should introduce a dependency on our `proxmox`
4 //! crate as that's where we have all this stuff usually...
6 use std
::os
::unix
::io
::{AsRawFd, FromRawFd, IntoRawFd, RawFd}
;
8 pub use io_uring
::iovec
::{IoVec, IoVecMut}
;
10 /// Guard a raw file descriptor with a drop handler. This is mostly useful when access to an owned
11 /// `RawFd` is required without the corresponding handler object (such as when only the file
12 /// descriptor number is required in a closure which may be dropped instead of being executed).
14 pub struct Fd(pub RawFd
);
16 file_descriptor_impl
!(Fd
);
18 impl FromRawFd
for Fd
{
19 unsafe fn from_raw_fd(fd
: RawFd
) -> Self {
24 /// Byte vector utilities.
26 /// Create an uninitialized byte vector of a specific size.
28 /// This is just a shortcut for:
30 /// # let len = 64usize;
31 /// let mut v = Vec::<u8>::with_capacity(len);
39 /// This is generally safe to call, but the contents of the vector are undefined.
41 pub unsafe fn uninitialized(len
: usize) -> Vec
<u8> {
42 let mut out
= Vec
::with_capacity(len
);
49 fn from_fd(fd
: Fd
) -> Self;
52 impl<T
: FromRawFd
> FromFd
for T
{
53 fn from_fd(fd
: Fd
) -> Self {
54 unsafe { Self::from_raw_fd(fd.into_raw_fd()) }