Fd

Enum Fd 

Source
pub enum Fd {
    ReadPipe,
    WritePipe,
    Inherit,
    ReadNull,
    WriteNull,
    Fd(Closing),
}
Expand description

An enumeration that is used to configure non-stdio file descriptors. It differs from stdio one because we must differentiate from readable and writable file descriptors for things open by the library

The enumeration members might be non-stable, it’s better to use one of the constructors to create an instance

Variants§

§

ReadPipe

This fd is a reading end of a pipe

§

WritePipe

This fd is a writing end of a pipe

§

Inherit

This fd is inherited from parent (current) process

§

ReadNull

This fd is redirected from /dev/null

§

WriteNull

This fd is redirected to /dev/null

§

Fd(Closing)

This is fd passed by application (and closed by unshare)

Implementations§

Source§

impl Fd

Source

pub fn piped_read() -> Fd

Create a pipe so that child can read from it

Source

pub fn piped_write() -> Fd

Create a pipe so that child can write to it

Source

pub fn inherit() -> Fd

Inherit the child descriptor from parent

Not very useful for custom file descriptors better use from_file()

Source

pub fn read_null() -> Fd

Create a readable pipe that always has end of file condition

Source

pub fn write_null() -> Fd

Create a writable pipe that ignores all the input

Source

pub fn dup_file<F: AsRawFd>(file: &F) -> Result<Fd>

A simpler helper method for from_raw_fd, that does dup of file descriptor, so is actually safe to use (but can fail)

Source

pub fn from_file<F: IntoRawFd>(file: F) -> Fd

A simpler helper method for from_raw_fd, that consumes file

Auto Trait Implementations§

§

impl Freeze for Fd

§

impl RefUnwindSafe for Fd

§

impl Send for Fd

§

impl Sync for Fd

§

impl Unpin for Fd

§

impl UnwindSafe for Fd

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> 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, 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.