pub mod headless;
pub use headless::Headless;
use crate::event::Event;
use crate::grid::{Pos, Size};
use crate::tile::Tile;
use core::time::Duration;
pub trait BackendError: core::fmt::Display + core::fmt::Debug {}
impl BackendError for core::convert::Infallible {}
#[cfg(feature = "std")]
impl BackendError for std::io::Error {}
pub trait Backend {
type Error: BackendError;
fn draw<'a, I>(&mut self, content: I) -> Result<(), Self::Error>
where
I: Iterator<Item = (Pos, &'a Tile)>;
fn draw_layers<'a, I>(&mut self, content: I) -> Result<(), Self::Error>
where
I: Iterator<Item = (u8, Pos, &'a Tile)>,
{
self.draw(content.filter_map(
|(layer, pos, tile)| {
if layer == 0 { Some((pos, tile)) } else { None }
},
))
}
fn needs_full_frame(&self) -> bool {
false
}
fn composites_layers(&self) -> bool {
false
}
fn flush(&mut self) -> Result<(), Self::Error>;
#[must_use]
fn size(&self) -> Size;
fn clear(&mut self) -> Result<(), Self::Error>;
fn resize(&mut self, size: Size) {
let _ = size;
}
fn poll_event(&mut self, timeout: Duration) -> Option<Event>;
fn set_cursor_visible(&mut self, visible: bool);
fn set_cursor_position(&mut self, position: Pos);
fn push_event(&mut self, _event: Event) {}
}