author | unc0rr |
Thu, 05 Jan 2017 19:07:01 +0300 | |
changeset 12130 | 6273f89ab13d |
parent 12129 | gameServer2/src/protocol.rs@07972a8c2433 |
child 12131 | a4d22f197bd2 |
permissions | -rw-r--r-- |
12129 | 1 |
use netbuf; |
2 |
use std::io::Read; |
|
3 |
use std::io::Result; |
|
4 |
||
12130 | 5 |
mod messages; |
6 |
mod hwprotocol; |
|
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 |
} |