1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use heapless;
use nb;
use tokenizer;
use tokenizer::{Tokenizer};
use lexer::{Lexer, CallbackCommand};
use hal::serial::Read;
pub struct LightCliInput<SLEN> where SLEN: heapless::ArrayLength<u8> {
tokenizer: Tokenizer<SLEN>,
lexer: Lexer<SLEN>
}
impl<SLEN : heapless::ArrayLength<u8>> LightCliInput<SLEN> {
pub fn new() -> Self {
Self {
tokenizer: Tokenizer::new(),
lexer: Lexer::new(),
}
}
pub fn parse_data<CB>(&mut self, callback: CB) -> nb::Result<(), tokenizer::Error>
where CB: FnMut(CallbackCommand) -> () {
self.lexer.parse_data(&mut self.tokenizer, callback)
}
pub fn fill<E>(&mut self, ser: &mut Read<u8, Error=E>) -> nb::Result<(), E> {
self.tokenizer.fill(ser)
}
}