Skip to main content

OpenFileKind

Enum OpenFileKind 

Source
pub enum OpenFileKind {
    File,
    Socket,
    Pipe,
    EventQueue,
    SharedMemory,
    Semaphore,
    Unknown,
}
Expand description

What kind of object a file descriptor refers to.

The set is the intersection of what both platforms can name from a single read: macOS’ proc_fdtype values and the prefix of a /proc/<pid>/fd/<n> link target. It exists because §4’s “unavailable is never an empty string” needs an answer for a descriptor that has no path at all — a socket is not a nameless file, it is a socket, and the kind is what says so.

Variants§

§

File

A file, directory, or device: something with a path in the filesystem.

§

Socket

A socket. Has no filesystem path unless it is a bound Unix socket, and neither platform reports that path through the descriptor table.

§

Pipe

A pipe or FIFO.

§

EventQueue

A kernel event queue: kqueue on macOS, epoll/eventfd/timerfd on Linux.

§

SharedMemory

POSIX shared memory.

§

Semaphore

A POSIX semaphore.

§

Unknown

The platform reported something we do not model.

Implementations§

Source§

impl OpenFileKind

Source

pub const fn label(self) -> &'static str

A lower-case label, in the same spirit as ProcessState::label.

Every label is strict 7-bit ASCII so it is legal in both glyph modes (§5.1).

Source

pub const fn has_path(self) -> bool

Whether a descriptor of this kind can have a filesystem path at all.

The one thing that distinguishes “the OS refused the path” from “there is no path to refuse”: a collector that cannot resolve a Self::File’s path has hit a permission or read failure, while a Self::Socket’s path is MetricState::Unsupported on every platform and always will be.

Trait Implementations§

Source§

impl Clone for OpenFileKind

Source§

fn clone(&self) -> OpenFileKind

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for OpenFileKind

Source§

impl Debug for OpenFileKind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for OpenFileKind

Source§

fn default() -> OpenFileKind

Returns the “default value” for a type. Read more
Source§

impl Eq for OpenFileKind

Source§

impl Hash for OpenFileKind

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for OpenFileKind

Source§

fn eq(&self, other: &OpenFileKind) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for OpenFileKind

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.