[][src]Trait gameshell::IncConsumer

pub trait IncConsumer {
    fn consume(&mut self, output: &mut [u8]) -> Consumption;
fn validate(&mut self, output: u8) -> Validation;
fn process(&mut self, input: &[u8]) -> Process; fn run(&mut self, buf: &mut [u8]) { ... } }

Incremental consumer of bytes

Consume bytes until a complete set of bytes has been found, then, run a handler function on just that set of bytes.

This is used for accepting bytes from some external stream, note that we set a maximum size on the buffer, so no external input can cause excessive memory usage.

Required methods

fn consume(&mut self, output: &mut [u8]) -> Consumption

Consume bytes and place them on an output stack

fn validate(&mut self, output: u8) -> Validation

Validate part of the bytestream, as soon as we return Validation::Ready, process will be run on the current accumulated bytes, after which these bytes will be deleted.

fn process(&mut self, input: &[u8]) -> Process

Process do actual stuff with the bytes to affect the system.

The sequence of bytes input here will have been verified by the validate function.

Loading content...

Provided methods

fn run(&mut self, buf: &mut [u8])

Runs the incremental consumer until it is signalled to quit

Loading content...

Implementors

impl<'a, C, R: Read, W: Write> IncConsumer for GameShell<'a, C, R, W>[src]

Loading content...