author | unc0rr |
Sun, 08 Jan 2017 23:57:45 +0300 | |
changeset 12133 | 81df2e1f9ae9 |
parent 12132 | 1525923cd7e3 |
child 12136 | e25a82ce2374 |
permissions | -rw-r--r-- |
12129 | 1 |
use netbuf; |
2 |
use std::io::Read; |
|
3 |
use std::io::Result; |
|
4 |
||
12130 | 5 |
mod messages; |
12133 | 6 |
mod parser; |
12129 | 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 |
} |