changeset 12130 | 6273f89ab13d |
parent 12129 | 07972a8c2433 |
child 12131 | a4d22f197bd2 |
12129:07972a8c2433 | 12130:6273f89ab13d |
---|---|
1 use netbuf; |
|
2 use std::io::Read; |
|
3 use std::io::Result; |
|
4 |
|
5 mod messages; |
|
6 mod hwprotocol; |
|
7 |
|
8 pub struct FrameDecoder { |
|
9 buf: netbuf::Buf, |
|
10 } |
|
11 |
|
12 impl FrameDecoder { |
|
13 pub fn new() -> FrameDecoder { |
|
14 FrameDecoder { |
|
15 buf: netbuf::Buf::new() |
|
16 } |
|
17 } |
|
18 |
|
19 pub fn read_from<R: Read>(&mut self, stream: &mut R) -> Result<usize> { |
|
20 self.buf.read_from(stream) |
|
21 } |
|
22 |
|
23 pub fn extract_messages(&mut self) -> &[u8] { |
|
24 &self.buf[..] |
|
25 } |
|
26 } |