Handler

Trait Handler 

Source
pub trait Handler {
    type OutputDevice;
    type Error;

    // Required method
    fn handle(
        &mut self,
        out: &mut Self::OutputDevice,
        input: &Action<'_>,
    ) -> Result<(), Self::Error>;
}
Expand description

A handler is a structure that can convert actions into an output on an output device. This simple trait is rather self-explanatory.

§Example

let mut grid = grid::Frame::new(0, 0, 10, 4).next_frame();
let mut process = grid.into_process(grid::DividerStrategy::Halfway);
process.add_to_section("Some stuff".to_string(), &mut Ignore, grid::Alignment::Plus);
let mut some_handler = out::OutToString;
let mut output_device = String::new();
process.print(&mut some_handler, &mut output_device)?;
assert_eq!(output_device, "          \n          \nSome stuff\n          \n".to_string());

Required Associated Types§

Required Methods§

Source

fn handle( &mut self, out: &mut Self::OutputDevice, input: &Action<'_>, ) -> Result<(), Self::Error>

Implementors§