pub trait IncConsumer {
    // Required methods
    fn consume(&mut self, output: &mut [u8]) -> Consumption;
    fn validate(&mut self, output: u8) -> Validation;
    fn process(&mut self, input: &[u8]) -> Process;

    // Provided method
    fn run(&mut self, buf: &mut [u8]) { ... }
}
Expand description

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§

source

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

Consume bytes and place them on an output stack

source

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.

source

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.

Provided Methods§

source

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

Runs the incremental consumer until it is signalled to quit

Implementors§

source§

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