pub trait ConsoleRead: Read {
// Required methods
fn get_event_and_raw(
&mut self,
timeout: Option<Duration>,
) -> Option<Result<(Event, Vec<u8>)>>;
fn poll(&mut self, timeout: Option<Duration>) -> bool;
fn read_timeout(
&mut self,
buf: &mut [u8],
timeout: Option<Duration>,
) -> Result<usize>;
}
Expand description
Console input trait.
Required Methods§
Sourcefn get_event_and_raw(
&mut self,
timeout: Option<Duration>,
) -> Option<Result<(Event, Vec<u8>)>>
fn get_event_and_raw( &mut self, timeout: Option<Duration>, ) -> Option<Result<(Event, Vec<u8>)>>
Get the next input event from the console and the bytes that define it. If timeout is not None then will return a WouldBlock error after timeout if no input. Returns None if the Console has no more data vs a read that would block.
Sourcefn poll(&mut self, timeout: Option<Duration>) -> bool
fn poll(&mut self, timeout: Option<Duration>) -> bool
Return when more data is avialable or timeout is reached. If timeout is None will poll until data is available. Returns true if more data was ready, false if timed out.
Calls to a get_* function or read should return data now. Assume this can be interupted.
Sourcefn read_timeout(
&mut self,
buf: &mut [u8],
timeout: Option<Duration>,
) -> Result<usize>
fn read_timeout( &mut self, buf: &mut [u8], timeout: Option<Duration>, ) -> Result<usize>
Read data (like read) but with an optional timeout. If timeout is None then block until there is something to read. If timeout is a value then return after the timeout if nothing is available to read. Returns a Err of kind WouldBlock if it times out.