logos.std.io.pipe

Module std · package logos-std

Types

structPipe

struct Pipe

Unix pipe: a connected read/write file-descriptor pair. Descriptors are NOT closed on drop; call close (or close_read/close_write) explicitly.

Implements: Read Write

Fields

read_fd: i32

Read end of the pipe; -1 when closed or on creation failure.

write_fd: i32

Write end of the pipe; -1 when closed or on creation failure.

Methods

fn close(self: &mut Pipe) -> void

Closes both ends of the pipe; idempotent.

fn close_read(self: &mut Pipe) -> void

Closes the read end and sets read_fd to -1; no-op if already closed.

fn close_write(self: &mut Pipe) -> void

Closes the write end and sets write_fd to -1; no-op if already closed.

fn flush(self: &mut Pipe) -> i64
fn is_valid(self: &Pipe) -> bool

Returns true if both pipe ends hold open (non-negative) descriptors.

fn read(self: &mut Pipe, buf: *mut u8, len: i64) -> i64
fn read_vectored(self: &mut Pipe, iovs: *mut IoSlice, nvecs: i32) -> i64

Performs a vectored read (readv) from the pipe’s read end. Returns bytes read (0 = EOF) or negative on error.

fn write(self: &mut Pipe, buf: *const u8, len: i64) -> i64
fn write_vectored(self: &mut Pipe, iovs: *const IoSlice, nvecs: i32) -> i64

Performs a vectored write (writev) to the pipe’s write end. Returns total bytes written (>= 0) or negative on error. IoSlice layout matches struct iovec.

Functions

fnpipe_new

fn pipe_new() -> Pipe

Creates a pipe via pipe2(2). Returns a Pipe with both ends open, or Pipe{-1,-1} on error.

fnpipe_new_nonblock

fn pipe_new_nonblock() -> Pipe

Creates a pipe with both ends in O_NONBLOCK mode. Returns Pipe{-1,-1} on error.