[][src]Struct crossterm::AsyncReader

pub struct AsyncReader { /* fields omitted */ }

This type allows you to read the input asynchronously which means that input events are gathered on the background and will be queued for you to read.

SyncReader If you want a blocking, or less resource consuming read to happen use SyncReader, this will leave a way all the thread and queueing and will be a blocking read.

This type is an iterator, and could be used to iterate over input events.

Remarks

  • Threads spawned will be disposed of as soon the AsyncReader goes out of scope.
  • MPSC-channels are used to queue input events, this type implements an iterator of the rx side of the queue.

Methods

impl AsyncReader[src]

Important traits for AsyncReader
pub fn new(
    function: Box<dyn Fn(&Sender<u8>, &Arc<AtomicBool>) + 'static + Send>
) -> AsyncReader
[src]

Construct a new instance of the AsyncReader. The reading will immediately start when calling this function.

pub fn stop(&mut self)[src]

Stop the input event reading.

You don't necessarily have to call this function because it will automatically be called when this reader goes out of scope.

Remarks

  • Background thread will be closed.
  • This will consume the handle you won't be able to restart the reading with this handle, create a new AsyncReader instead.

Trait Implementations

impl Iterator for AsyncReader[src]

type Item = InputEvent

The type of the elements being iterated over.

fn next(&mut self) -> Option<<AsyncReader as Iterator>::Item>[src]

Check if there are input events to read.

It will return None when nothing is there to read, Some(InputEvent) if there are events to read.

Remark

  • This is not a blocking call.

impl Drop for AsyncReader[src]

Auto Trait Implementations

Blanket Implementations

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

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

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

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.

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.

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

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

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