#[cfg(not(unix))]
compile_error!("unix-ancillary only supports Unix platforms");
mod ancillary;
mod cmsg;
mod ext;
pub use ancillary::{AncillaryData, AncillaryError, Messages, ScmRights, SocketAncillary};
pub use ext::{UnixDatagramExt, UnixStreamExt};
use std::io;
use std::os::unix::io::BorrowedFd;
pub fn cmsg_sendmsg(
fd: BorrowedFd<'_>,
iov: &[io::IoSlice<'_>],
ancillary: &SocketAncillary<'_>,
) -> io::Result<usize> {
cmsg::sendmsg_vectored(fd, iov, ancillary.buffer, ancillary.length)
}
pub fn cmsg_recvmsg(
fd: BorrowedFd<'_>,
iov: &mut [io::IoSliceMut<'_>],
ancillary: &mut SocketAncillary<'_>,
) -> io::Result<usize> {
let result = cmsg::recvmsg_vectored(fd, iov, ancillary.buffer)?;
ancillary.length = result.ancillary_len;
ancillary.truncated = result.truncated;
Ok(result.bytes_read)
}