pub struct Parser<const OSC_RAW_BUF_SIZE: usize = MAX_OSC_RAW> { /* private fields */ }
Expand description
Parser for raw VTE protocol which delegates actions to a Perform
Generic over the value for the size of the raw Operating System Command
buffer. Only used when the std
feature is not enabled.
Implementations§
Source§impl Parser
impl Parser
Sourcepub fn new() -> Parser
pub fn new() -> Parser
Create a new Parser
Examples found in repository?
examples/parselog.rs (line 56)
52fn main() {
53 let input = io::stdin();
54 let mut handle = input.lock();
55
56 let mut statemachine = Parser::new();
57 let mut performer = Log;
58
59 let mut buf = [0; 2048];
60
61 loop {
62 match handle.read(&mut buf) {
63 Ok(0) => break,
64 Ok(n) => statemachine.advance(&mut performer, &buf[..n]),
65 Err(err) => {
66 println!("err: {}", err);
67 break;
68 },
69 }
70 }
71}
Source§impl<const OSC_RAW_BUF_SIZE: usize> Parser<OSC_RAW_BUF_SIZE>
impl<const OSC_RAW_BUF_SIZE: usize> Parser<OSC_RAW_BUF_SIZE>
Sourcepub fn advance<P: Perform>(&mut self, performer: &mut P, bytes: &[u8])
pub fn advance<P: Perform>(&mut self, performer: &mut P, bytes: &[u8])
Advance the parser state.
Requires a Perform
implementation to handle the triggered actions.
Examples found in repository?
examples/parselog.rs (line 64)
52fn main() {
53 let input = io::stdin();
54 let mut handle = input.lock();
55
56 let mut statemachine = Parser::new();
57 let mut performer = Log;
58
59 let mut buf = [0; 2048];
60
61 loop {
62 match handle.read(&mut buf) {
63 Ok(0) => break,
64 Ok(n) => statemachine.advance(&mut performer, &buf[..n]),
65 Err(err) => {
66 println!("err: {}", err);
67 break;
68 },
69 }
70 }
71}
Sourcepub fn advance_until_terminated<P: Perform>(
&mut self,
performer: &mut P,
bytes: &[u8],
) -> usize
pub fn advance_until_terminated<P: Perform>( &mut self, performer: &mut P, bytes: &[u8], ) -> usize
Partially advance the parser state.
This is equivalent to Self::advance
, but stops when
Perform::terminated
is true after reading a byte.
Returns the number of bytes read before termination.
See [Perform::advance
] for more details.
Trait Implementations§
Auto Trait Implementations§
impl<const OSC_RAW_BUF_SIZE: usize> Freeze for Parser<OSC_RAW_BUF_SIZE>
impl<const OSC_RAW_BUF_SIZE: usize> RefUnwindSafe for Parser<OSC_RAW_BUF_SIZE>
impl<const OSC_RAW_BUF_SIZE: usize> Send for Parser<OSC_RAW_BUF_SIZE>
impl<const OSC_RAW_BUF_SIZE: usize> Sync for Parser<OSC_RAW_BUF_SIZE>
impl<const OSC_RAW_BUF_SIZE: usize> Unpin for Parser<OSC_RAW_BUF_SIZE>
impl<const OSC_RAW_BUF_SIZE: usize> UnwindSafe for Parser<OSC_RAW_BUF_SIZE>
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