pub struct Parser { /* private fields */ }Expand description
An incremental parser for terminal input.
The parser keeps incomplete escape sequences in an internal buffer. Pass maybe_more = true
when the current byte slice may end in the middle of a sequence. Completed events are queued
until Self::pop removes them.
§Examples
use termina::{Event, Parser};
let mut parser = Parser::default();
parser.parse(b"\x1b[5~", false);
assert!(matches!(parser.pop(), Some(Event::Key(_))));Implementations§
Source§impl Parser
impl Parser
Sourcepub fn parse(&mut self, bytes: &[u8], maybe_more: bool)
pub fn parse(&mut self, bytes: &[u8], maybe_more: bool)
Adds bytes to the parser and queues any completed events.
Set maybe_more to true when the input source may provide more bytes for the same
escape sequence later. Set it to false when the buffer should be treated as complete for
now; malformed or incomplete sequences can then be discarded instead of held indefinitely.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Parser
impl RefUnwindSafe for Parser
impl Send for Parser
impl Sync for Parser
impl Unpin for Parser
impl UnsafeUnpin for Parser
impl UnwindSafe for Parser
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more