Skip to main content

Out

Struct Out 

Source
pub struct Out {
    pub fd: usize,
    buf: Vec<u8>,
    pub failed: bool,
    pub color: ColorMode,
    redirect: Option<usize>,
    pub pending: Vec<u8>,
    pub interrupted: bool,
    pub peer_closed: bool,
    poll_tick: u32,
}

Fields§

§fd: usize§buf: Vec<u8>§failed: bool

Set once a network write failed: commands should stop producing output.

§color: ColorMode§redirect: Option<usize>

When set, output goes (raw) to this file fd instead of the socket.

§pending: Vec<u8>

Raw bytes received from the client while a command was running.

§interrupted: bool

Ctrl-C seen while a command was running.

§peer_closed: bool§poll_tick: u32

Implementations§

Source§

impl Out

Source

pub fn new(fd: usize) -> Self

Source

pub fn set_redirect(&mut self, fd: Option<usize>)

Source

pub fn redirected(&self) -> bool

Source

pub fn stop(&mut self) -> bool

True if output should stop (client gone, write failed or Ctrl-C).

Source

fn poll_input(&mut self)

Cheaply look for Ctrl-C (and stash anything else as type-ahead).

Source

pub fn flush(&mut self)

Source

fn push(&mut self, b: u8)

Source

pub fn text(&mut self, s: &str)

Terminal text: \n becomes CRLF, 0xFF is IAC-escaped.

Source

fn byte(&mut self, b: u8)

Source

pub fn raw(&mut self, bytes: &[u8])

Raw protocol bytes (telnet commands, escape sequences): no translation.

Source

pub fn data(&mut self, bytes: &[u8])

File content: control characters (including ESC) are neutralised so a binary file cannot corrupt the terminal. Redirected output is raw.

Source

pub fn style(&mut self, s: Style)

Source

pub fn styled(&mut self, st: Style, s: &str)

Print s in style st, then reset.

Source

pub fn error(&mut self, cmd: &str, detail: Arguments<'_>)

cmd: detail error line in red.

Trait Implementations§

Source§

impl Write for Out

Source§

fn write_str(&mut self, s: &str) -> Result

Writes a string slice into this writer, returning whether the write succeeded. Read more
1.1.0 · Source§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more

Auto Trait Implementations§

§

impl Forget for Out

§

impl Freeze for Out

§

impl Move for Out

§

impl RefUnwindSafe for Out

§

impl Send for Out

§

impl Sync for Out

§

impl Unpin for Out

§

impl UnsafeUnpin for Out

§

impl UnwindSafe for Out

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.