author | unc0rr |
Tue, 03 Jan 2017 00:19:47 +0300 | |
changeset 12129 | 07972a8c2433 |
permissions | -rw-r--r-- |
12129 | 1 |
use netbuf; |
2 |
use std::io::Read; |
|
3 |
use std::io::Result; |
|
4 |
||
5 |
||
6 |
pub struct FrameDecoder { |
|
7 |
buf: netbuf::Buf, |
|
8 |
} |
|
9 |
||
10 |
impl FrameDecoder { |
|
11 |
pub fn new() -> FrameDecoder { |
|
12 |
FrameDecoder { |
|
13 |
buf: netbuf::Buf::new() |
|
14 |
} |
|
15 |
} |
|
16 |
||
17 |
pub fn read_from<R: Read>(&mut self, stream: &mut R) -> Result<usize> { |
|
18 |
self.buf.read_from(stream) |
|
19 |
} |
|
20 |
||
21 |
pub fn extract_messages(&mut self) -> &[u8] { |
|
22 |
&self.buf[..] |
|
23 |
} |
|
24 |
} |