Strategy

Trait Strategy 

Source
pub trait Strategy {
    // Required methods
    fn process(&mut self, input: &[u8]) -> Result<Vec<Output>, General>;
    fn terminate(&mut self) -> Result<Vec<Output>, General>;
}

Required Methods§

Source

fn process(&mut self, input: &[u8]) -> Result<Vec<Output>, General>

Processes input data

§Arguments
  • input - input data
§Returns
  • `Ok(_) processing passed
  • Err(_) - error occured during processing
§Errors

If parsing logic finds that JSON is not valid, it returns error::General.

Note that streamson assumes that its input is a valid JSONs and if not, it still might be processed without an error. This is caused because streamson does not validate JSON.

Source

fn terminate(&mut self) -> Result<Vec<Output>, General>

Should be called when input data terminates

§Returns
  • `Ok(_) processing passed
  • Err(_) - error occured during processing
§Errors

Should return an error if strategy is in unterminated state (still expects data in input)

Implementors§