gameServer2/src/protocol/mod.rs
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--
Start on messages parser

use netbuf;
use std::io::Read;
use std::io::Result;

mod messages;
mod hwprotocol;

pub struct FrameDecoder {
    buf: netbuf::Buf,
}

impl FrameDecoder {
    pub fn new() -> FrameDecoder {
        FrameDecoder {
            buf: netbuf::Buf::new()
        }
    }

    pub fn read_from<R: Read>(&mut self, stream: &mut R) -> Result<usize> {
        self.buf.read_from(stream)
    }

    pub fn extract_messages(&mut self) -> &[u8] {
        &self.buf[..]
    }
}