#[repr(transparent)]pub struct FdSet<'fd> { /* private fields */ }
Available on crate feature
poll
only.Expand description
Contains a set of file descriptors used by select
Implementations§
source§impl<'fd> FdSet<'fd>
impl<'fd> FdSet<'fd>
sourcepub fn contains<Fd: AsFd>(&self, fd: &'fd Fd) -> bool
pub fn contains<Fd: AsFd>(&self, fd: &'fd Fd) -> bool
Test an FdSet
for the presence of a certain file descriptor.
sourcepub fn highest(&self) -> Option<BorrowedFd<'_>>
pub fn highest(&self) -> Option<BorrowedFd<'_>>
Finds the highest file descriptor in the set.
Returns None
if the set is empty.
This can be used to calculate the nfds
parameter of the select
function.
Example
let fd_four = unsafe {BorrowedFd::borrow_raw(4)};
let fd_nine = unsafe {BorrowedFd::borrow_raw(9)};
let mut set = FdSet::new();
set.insert(&fd_four);
set.insert(&fd_nine);
assert_eq!(set.highest().map(|borrowed_fd|borrowed_fd.as_raw_fd()), Some(9));
sourcepub fn fds(&self, highest: Option<RawFd>) -> Fds<'_, '_> ⓘ
pub fn fds(&self, highest: Option<RawFd>) -> Fds<'_, '_> ⓘ
Returns an iterator over the file descriptors in the set.
For performance, it takes an optional higher bound: the iterator will not return any elements of the set greater than the given file descriptor.
Examples
let mut set = FdSet::new();
let fd_four = unsafe {BorrowedFd::borrow_raw(4)};
let fd_nine = unsafe {BorrowedFd::borrow_raw(9)};
set.insert(&fd_four);
set.insert(&fd_nine);
let fds: Vec<RawFd> = set.fds(None).map(|borrowed_fd|borrowed_fd.as_raw_fd()).collect();
assert_eq!(fds, vec![4, 9]);
Trait Implementations§
source§impl<'fd> PartialEq<FdSet<'fd>> for FdSet<'fd>
impl<'fd> PartialEq<FdSet<'fd>> for FdSet<'fd>
impl<'fd> Copy for FdSet<'fd>
impl<'fd> Eq for FdSet<'fd>
impl<'fd> StructuralEq for FdSet<'fd>
impl<'fd> StructuralPartialEq for FdSet<'fd>
Auto Trait Implementations§
impl<'fd> RefUnwindSafe for FdSet<'fd>
impl<'fd> Send for FdSet<'fd>
impl<'fd> Sync for FdSet<'fd>
impl<'fd> Unpin for FdSet<'fd>
impl<'fd> UnwindSafe for FdSet<'fd>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more