Skip to main content

FdSet

Trait FdSet 

Source
pub trait FdSet:
    Clone
    + Default
    + 'static {
    const MAX_FD: Fd;

    // Required methods
    fn insert(&mut self, fd: Fd);
    fn remove(&mut self, fd: Fd);
    fn contains(&self, fd: Fd) -> bool;

    // Provided methods
    fn new() -> Self { ... }
    fn from_fds<I>(iter: I) -> Self
       where I: IntoIterator<Item = Fd> { ... }
}
Expand description

Trait for representing a set of file descriptors (FDs)

This is an abstraction over the fd_set type used in the select system call. It represents a set of Fds that can be monitored for events such as readability or writability.

As per POSIX, an fd_set can only contain FDs in the range of 0 to FD_SETSIZE - 1. The MAX_FD associated constant in this trait represents the maximum FD that can be stored in the set.

Required Associated Constants§

Source

const MAX_FD: Fd

The maximum FD that can be stored in the set. This corresponds to FD_SETSIZE - 1 in C libraries. The exact value may depend on the implementation.

Required Methods§

Source

fn insert(&mut self, fd: Fd)

Adds an FD to the set.

If the provided FD is greater than MAX_FD or negative, it will be silently ignored.

Source

fn remove(&mut self, fd: Fd)

Removes an FD from the set.

If the provided FD is greater than MAX_FD or negative, it will be silently ignored.

Source

fn contains(&self, fd: Fd) -> bool

Checks if an FD is in the set.

If the provided FD is greater than MAX_FD or negative, this function will return false.

Provided Methods§

Source

fn new() -> Self

Creates a new, empty FD set.

The provided implementation simply calls Default::default.

Source

fn from_fds<I>(iter: I) -> Self
where I: IntoIterator<Item = Fd>,

Creates a new FD set from an iterator of FDs.

This is a convenience method that creates a new FD set and inserts all the FDs from the provided iterator into it. If any FD in the iterator is greater than MAX_FD or negative, it will be silently ignored.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl FdSet for yash_env::system::real::FdSet

Source§

impl FdSet for yash_env::system::virtual::fd_set::FdSet