Struct nix::sys::select::FdSet

#[repr(transparent)]
pub struct FdSet(_);
Documentation

Contains a set of file descriptors used by select

Implementations

impl FdSet
pub fn new() -> FdSet

Create an empty FdSet

pub fn insert(&mut Self, fd: RawFd)

Add a file descriptor to an FdSet

pub fn remove(&mut Self, fd: RawFd)

Remove a file descriptor from an FdSet

pub fn contains(&Self, fd: RawFd) -> bool

Test an FdSet for the presence of a certain file descriptor.

pub fn clear(&mut Self)

Remove all file descriptors from this FdSet.

pub fn highest(&Self) -> Option<RawFd>

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 mut set = FdSet::new();
set.insert(4);
set.insert(9);
assert_eq!(set.highest(), Some(9));
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();
set.insert(4);
set.insert(9);
let fds: Vec<RawFd> = set.fds(None).collect();
assert_eq!(fds, vec![4, 9]);

Trait Implementations

impl Clone for FdSet
fn clone(&Self) -> FdSet
impl Copy for FdSet
impl Debug for FdSet
fn fmt(&Self, f: &mut $crate::fmt::Formatter<'_>) -> $crate::fmt::Result
impl Default for FdSet
fn default() -> Self
impl Eq for FdSet
impl Hash for FdSet
fn hash<__H: $crate::hash::Hasher>(&Self, state: &mut __H) -> ()
impl PartialEq<FdSet> for FdSet
fn eq(&Self, other: &FdSet) -> bool
fn ne(&Self, other: &FdSet) -> bool
impl StructuralEq for FdSet

Auto Trait Implementations

impl RefUnwindSafe for FdSet
impl Send for FdSet
impl Sync for FdSet
impl Unpin for FdSet
impl UnwindSafe for FdSet

Blanket Implementations

impl<T> Any for T
where
    T: 'static + ?Sized,
fn type_id(&Self) -> TypeId
impl<T> Borrow<T> for T
where
    T: ?Sized,
fn borrow(&Self) -> &T
impl<T> BorrowMut<T> for T
where
    T: ?Sized,
fn borrow_mut(&mut Self) -> &mut T
impl<T> From<T> for T
fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into<U> for T
where
    U: From<T>,
fn into(Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

impl<T> ToOwned for T
where
    T: Clone,
type Owned = T
fn to_owned(&Self) -> T
fn clone_into(&Self, target: &mut T)
impl<T, U> TryFrom<U> for T
where
    U: Into<T>,
type Error = Infallible
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for T
where
    U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
fn try_into(Self) -> Result<U, <U as TryFrom<T>>::Error>