Struct Pipe

Source
pub struct Pipe { /* private fields */ }
Expand description

Abstraction over UNIX pipe for the specific case here with stdin/stdout redirection between processes. The typical flow is that a Pipe is created, the program is forked and that one process marks it’s part of the Pipe as READ while the other process marks it’s part of the Pipe as WRITE.

Each Pipe object will exists per address space, because we create a child process for each command to be executed.

Each pipe connects two processes. Each process has access to “pipe_to_current” and “pipe_to_next”. First one is used as READ-end while the latter one is used as WRITE-end.

Implementations§

Source§

impl Pipe

Source

pub fn new() -> Self

Source

pub fn as_read_end(&mut self)

Marks and locks the Pipe in the current address space as read end.

Source

pub fn as_write_end(&mut self)

Marks and locks the Pipe in the current address space as write end.

Source

pub fn parent_close_all(&mut self)

A parent doesn’t uses the pipes. It just creates the objects and make sure they are transferred into the childs (via fork(). After a child process started and got it’s Pipe objects, the parent MUST close it’s FDs in order to prevent deadlocks.

Trait Implementations§

Source§

impl Debug for Pipe

Source§

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

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

impl Drop for Pipe

Source§

fn drop(&mut self)

Makes sure all FD’s are closed when Pipe is dropped.

Auto Trait Implementations§

§

impl Freeze for Pipe

§

impl RefUnwindSafe for Pipe

§

impl Send for Pipe

§

impl Sync for Pipe

§

impl Unpin for Pipe

§

impl UnwindSafe for Pipe

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.