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§
Sourcefn new(window: &Window, resolution: (u32, u32), scale: u32) -> Option<Self>
fn new(window: &Window, resolution: (u32, u32), scale: u32) -> Option<Self>
Create new backend instance.
Sourcefn resize(&mut self, width: NonZeroU32, height: NonZeroU32) -> Option<()>
fn resize(&mut self, width: NonZeroU32, height: NonZeroU32) -> Option<()>
Handle resize event.
Sourcefn 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<()>
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<()>
Draw image on the backend.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".