Skip to main content

Backend

Trait Backend 

Source
pub trait Backend: Sized {
    // Required methods
    fn new(window: &Window, resolution: (u32, u32), scale: u32) -> Option<Self>;
    fn resize(&mut self, width: NonZeroU32, height: NonZeroU32) -> Option<()>;
    fn draw_image<'a, P: 'a, I>(
        &mut self,
        image: &'a dyn BackendImage<'a, P, Iterator = I>,
        converter: &dyn Converter<Palette = P>,
        window: &Window,
        background: u32,
    ) -> Option<()>
       where I: Iterator<Item = &'a P>;
    fn window_pos_to_inner(
        &self,
        position: PhysicalPosition<f64>,
        window: &Window,
        resolution: (u32, u32),
    ) -> Result<(i32, i32), (i32, i32)>;
}
Expand description

Backend trait. It provides functions to:

  • create new instance;
  • handle resize events;
  • to draw output;
  • recalculate pointer position to canvas space.

Required Methods§

Source

fn new(window: &Window, resolution: (u32, u32), scale: u32) -> Option<Self>

Create new backend instance.

Source

fn resize(&mut self, width: NonZeroU32, height: NonZeroU32) -> Option<()>

Handle resize event.

Source

fn draw_image<'a, P: 'a, I>( &mut self, image: &'a dyn BackendImage<'a, P, Iterator = I>, converter: &dyn Converter<Palette = P>, window: &Window, background: u32, ) -> Option<()>
where I: Iterator<Item = &'a P>,

Draw image on the backend.

Source

fn window_pos_to_inner( &self, position: PhysicalPosition<f64>, window: &Window, resolution: (u32, u32), ) -> Result<(i32, i32), (i32, i32)>

Recalculate pointer position to canvas space.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§