[][src]Trait linefeed::terminal::TerminalReader

pub trait TerminalReader<Term: Terminal> {
    fn prepare(
        &mut self,
        block_signals: bool,
        report_signals: SignalSet
    ) -> Result<Term::PrepareState>;
unsafe fn prepare_with_lock(
        &mut self,
        lock: &mut dyn TerminalWriter<Term>,
        block_signals: bool,
        report_signals: SignalSet
    ) -> Result<Term::PrepareState>;
fn restore(&mut self, state: Term::PrepareState) -> Result<()>;
unsafe fn restore_with_lock(
        &mut self,
        lock: &mut dyn TerminalWriter<Term>,
        state: Term::PrepareState
    ) -> Result<()>;
fn read(&mut self, buf: &mut Vec<u8>) -> Result<RawRead>;
fn wait_for_input(&mut self, timeout: Option<Duration>) -> Result<bool>; }

Holds a lock on Terminal read operations

Required methods

fn prepare(
    &mut self,
    block_signals: bool,
    report_signals: SignalSet
) -> Result<Term::PrepareState>

Prepares the terminal for line reading and editing operations.

If block_signals is true, the terminal will be configured to treat special characters that would otherwise be interpreted as signals as their literal value.

If block_signals is false, a signal contained in the report_signals set may be returned.

Notes

This method may be called more than once. However, if the state values are not restored in reverse order in which they were created, the state of the underlying terminal device becomes undefined.

unsafe fn prepare_with_lock(
    &mut self,
    lock: &mut dyn TerminalWriter<Term>,
    block_signals: bool,
    report_signals: SignalSet
) -> Result<Term::PrepareState>

Like prepare, but called when the write lock is already held.

Safety

This method must be called with a TerminalWriter instance returned by the same Terminal instance to which this TerminalReader belongs.

fn restore(&mut self, state: Term::PrepareState) -> Result<()>

Restores the terminal state using the given state data.

unsafe fn restore_with_lock(
    &mut self,
    lock: &mut dyn TerminalWriter<Term>,
    state: Term::PrepareState
) -> Result<()>

Like restore, but called when the write lock is already held.

Safety

This method must be called with a TerminalWriter instance returned by the same Terminal instance to which this TerminalReader belongs.

fn read(&mut self, buf: &mut Vec<u8>) -> Result<RawRead>

Reads some input from the terminal and appends it to the given buffer.

fn wait_for_input(&mut self, timeout: Option<Duration>) -> Result<bool>

Waits timeout for user input. If timeout is None, waits indefinitely.

Returns Ok(true) if input becomes available within the given timeout or if a signal is received.

Returns Ok(false) if the timeout expires before input becomes available.

Loading content...

Implementations on Foreign Types

impl<'a> TerminalReader<DefaultTerminal> for TerminalReadGuard<'a>[src]

Loading content...

Implementors

impl<'a> TerminalReader<MemoryTerminal> for MemoryReadGuard<'a>[src]

Loading content...