Struct console::Term[][src]

pub struct Term { /* fields omitted */ }
Expand description

Abstraction around a terminal.

A terminal can be cloned. If a buffer is used it’s shared across all clones which means it largely acts as a handle.

Implementations

impl Term[src]

pub fn stdout() -> Term

Notable traits for Term

impl Read for Termimpl<'a> Read for &'a Termimpl Write for Termimpl<'a> Write for &'a Term
[src]

Return a new unbuffered terminal

pub fn stderr() -> Term

Notable traits for Term

impl Read for Termimpl<'a> Read for &'a Termimpl Write for Termimpl<'a> Write for &'a Term
[src]

Return a new unbuffered terminal to stderr

pub fn buffered_stdout() -> Term

Notable traits for Term

impl Read for Termimpl<'a> Read for &'a Termimpl Write for Termimpl<'a> Write for &'a Term
[src]

Return a new buffered terminal

pub fn buffered_stderr() -> Term

Notable traits for Term

impl Read for Termimpl<'a> Read for &'a Termimpl Write for Termimpl<'a> Write for &'a Term
[src]

Return a new buffered terminal to stderr

pub fn target(&self) -> TermTarget[src]

Returns the targert

pub fn write_line(&self, s: &str) -> Result<()>[src]

Writes a string to the terminal and adds a newline.

pub fn read_char(&self) -> Result<char>[src]

Read a single character from the terminal

This does not echo the character and blocks until a single character is entered.

pub fn read_key(&self) -> Result<Key>[src]

Read a single key form the terminal.

This does not echo anything. If the terminal is not user attended the return value will always be the unknown key.

pub fn read_line(&self) -> Result<String>[src]

Read one line of input.

This does not include the trailing newline. If the terminal is not user attended the return value will always be an empty string.

pub fn read_line_initial_text(&self, initial: &str) -> Result<String>[src]

Read one line of input with initial text.

This does not include the trailing newline. If the terminal is not user attended the return value will always be an empty string.

pub fn read_secure_line(&self) -> Result<String>[src]

Read securely a line of input.

This is similar to read_line but will not echo the output. This also switches the terminal into a different mode where not all characters might be accepted.

pub fn flush(&self) -> Result<()>[src]

Flushes internal buffers.

This forces the contents of the internal buffer to be written to the terminal. This is unnecessary for unbuffered terminals which will automatically flush.

pub fn is_term(&self) -> bool[src]

Checks if the terminal is indeed a terminal.

This is a shortcut for features().is_attended().

pub fn features(&self) -> TermFeatures<'_>[src]

Checks for common terminal features.

pub fn want_emoji(&self) -> bool[src]

👎 Deprecated since 0.8.0:

Use features().wants_emoji() instead

Checks if this terminal wants emoji output.

pub fn size(&self) -> (u16, u16)[src]

Returns the terminal size or gets sensible defaults.

pub fn size_checked(&self) -> Option<(u16, u16)>[src]

Returns the terminal size in rows and columns.

If the size cannot be reliably determined None is returned.

pub fn move_cursor_to(&self, x: usize, y: usize) -> Result<()>[src]

Moves the cursor to x and y

pub fn move_cursor_up(&self, n: usize) -> Result<()>[src]

Moves the cursor up n lines

pub fn move_cursor_down(&self, n: usize) -> Result<()>[src]

Moves the cursor down n lines

pub fn clear_line(&self) -> Result<()>[src]

Clears the current line.

The positions the cursor at the beginning of the line again.

pub fn clear_last_lines(&self, n: usize) -> Result<()>[src]

Clear the last n lines.

This positions the cursor at the beginning of the first line that was cleared.

pub fn clear_screen(&self) -> Result<()>[src]

Clears the entire screen.

pub fn clear_chars(&self, n: usize) -> Result<()>[src]

Clears the last char in the the current line.

pub fn set_title<T: Display>(&self, title: T)[src]

Set the terminal title

pub fn show_cursor(&self) -> Result<()>[src]

Makes cursor visible again

pub fn hide_cursor(&self) -> Result<()>[src]

Hides cursor

Trait Implementations

impl AsRawFd for Term[src]

fn as_raw_fd(&self) -> RawFd[src]

Extracts the raw file descriptor. Read more

impl Clone for Term[src]

fn clone(&self) -> Term

Notable traits for Term

impl Read for Termimpl<'a> Read for &'a Termimpl Write for Termimpl<'a> Write for &'a Term
[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Term[src]

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

Formats the value using the given formatter. Read more

impl Read for Term[src]

fn read(&mut self, buf: &mut [u8]) -> Result<usize>[src]

Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more

fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>1.36.0[src]

Like read, except that it reads into a slice of buffers. Read more

fn is_read_vectored(&self) -> bool[src]

🔬 This is a nightly-only experimental API. (can_vector)

Determines if this Reader has an efficient read_vectored implementation. Read more

unsafe fn initializer(&self) -> Initializer[src]

🔬 This is a nightly-only experimental API. (read_initializer)

Determines if this Reader can work with buffers of uninitialized memory. Read more

fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>1.0.0[src]

Read all bytes until EOF in this source, placing them into buf. Read more

fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>1.0.0[src]

Read all bytes until EOF in this source, appending them to buf. Read more

fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>1.6.0[src]

Read the exact number of bytes required to fill buf. Read more

fn by_ref(&mut self) -> &mut Self1.0.0[src]

Creates a “by reference” adaptor for this instance of Read. Read more

fn bytes(self) -> Bytes<Self>1.0.0[src]

Transforms this Read instance to an Iterator over its bytes. Read more

fn chain<R>(self, next: R) -> Chain<Self, R> where
    R: Read
1.0.0[src]

Creates an adaptor which will chain this stream with another. Read more

fn take(self, limit: u64) -> Take<Self>1.0.0[src]

Creates an adaptor which will read at most limit bytes from it. Read more

impl<'a> Read for &'a Term[src]

fn read(&mut self, buf: &mut [u8]) -> Result<usize>[src]

Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more

fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>1.36.0[src]

Like read, except that it reads into a slice of buffers. Read more

fn is_read_vectored(&self) -> bool[src]

🔬 This is a nightly-only experimental API. (can_vector)

Determines if this Reader has an efficient read_vectored implementation. Read more

unsafe fn initializer(&self) -> Initializer[src]

🔬 This is a nightly-only experimental API. (read_initializer)

Determines if this Reader can work with buffers of uninitialized memory. Read more

fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>1.0.0[src]

Read all bytes until EOF in this source, placing them into buf. Read more

fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>1.0.0[src]

Read all bytes until EOF in this source, appending them to buf. Read more

fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>1.6.0[src]

Read the exact number of bytes required to fill buf. Read more

fn by_ref(&mut self) -> &mut Self1.0.0[src]

Creates a “by reference” adaptor for this instance of Read. Read more

fn bytes(self) -> Bytes<Self>1.0.0[src]

Transforms this Read instance to an Iterator over its bytes. Read more

fn chain<R>(self, next: R) -> Chain<Self, R> where
    R: Read
1.0.0[src]

Creates an adaptor which will chain this stream with another. Read more

fn take(self, limit: u64) -> Take<Self>1.0.0[src]

Creates an adaptor which will read at most limit bytes from it. Read more

impl Write for Term[src]

fn write(&mut self, buf: &[u8]) -> Result<usize>[src]

Write a buffer into this writer, returning how many bytes were written. Read more

fn flush(&mut self) -> Result<()>[src]

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>1.36.0[src]

Like write, except that it writes from a slice of buffers. Read more

fn is_write_vectored(&self) -> bool[src]

🔬 This is a nightly-only experimental API. (can_vector)

Determines if this Writer has an efficient write_vectored implementation. Read more

fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>1.0.0[src]

Attempts to write an entire buffer into this writer. Read more

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>[src]

🔬 This is a nightly-only experimental API. (write_all_vectored)

Attempts to write multiple buffers into this writer. Read more

fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>1.0.0[src]

Writes a formatted string into this writer, returning any error encountered. Read more

fn by_ref(&mut self) -> &mut Self1.0.0[src]

Creates a “by reference” adaptor for this instance of Write. Read more

impl<'a> Write for &'a Term[src]

fn write(&mut self, buf: &[u8]) -> Result<usize>[src]

Write a buffer into this writer, returning how many bytes were written. Read more

fn flush(&mut self) -> Result<()>[src]

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>1.36.0[src]

Like write, except that it writes from a slice of buffers. Read more

fn is_write_vectored(&self) -> bool[src]

🔬 This is a nightly-only experimental API. (can_vector)

Determines if this Writer has an efficient write_vectored implementation. Read more

fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>1.0.0[src]

Attempts to write an entire buffer into this writer. Read more

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>[src]

🔬 This is a nightly-only experimental API. (write_all_vectored)

Attempts to write multiple buffers into this writer. Read more

fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>1.0.0[src]

Writes a formatted string into this writer, returning any error encountered. Read more

fn by_ref(&mut self) -> &mut Self1.0.0[src]

Creates a “by reference” adaptor for this instance of Write. Read more

Auto Trait Implementations

impl RefUnwindSafe for Term

impl Send for Term

impl Sync for Term

impl Unpin for Term

impl UnwindSafe for Term

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.