author | unc0rr |
Sat, 07 Jan 2017 21:34:00 +0300 | |
changeset 12132 | 1525923cd7e3 |
parent 12131 | a4d22f197bd2 |
child 12133 | 81df2e1f9ae9 |
permissions | -rw-r--r-- |
12129 | 1 |
use netbuf; |
2 |
use std::io::Read; |
|
3 |
use std::io::Result; |
|
4 |
||
12130 | 5 |
mod messages; |
12129 | 6 |
|
7 |
pub struct FrameDecoder { |
|
8 |
buf: netbuf::Buf, |
|
9 |
} |
|
10 |
||
11 |
impl FrameDecoder { |
|
12 |
pub fn new() -> FrameDecoder { |
|
13 |
FrameDecoder { |
|
14 |
buf: netbuf::Buf::new() |
|
15 |
} |
|
16 |
} |
|
17 |
||
18 |
pub fn read_from<R: Read>(&mut self, stream: &mut R) -> Result<usize> { |
|
19 |
self.buf.read_from(stream) |
|
20 |
} |
|
21 |
||
22 |
pub fn extract_messages(&mut self) -> &[u8] { |
|
23 |
&self.buf[..] |
|
24 |
} |
|
25 |
} |