use std::io;
use crate::charsets;
#[derive(Clone, Debug)]
pub struct RenderOptions<'a> {
pub width: Option<u32>,
pub height: Option<u32>,
pub colored: bool,
pub invert: bool,
pub charset: &'a [&'a str],
}
#[allow(dead_code)]
impl<'a> RenderOptions<'a> {
pub fn new() -> Self {
Self::default()
}
pub fn width(mut self, width: u32) -> Self {
self.width = Some(width);
self
}
pub fn height(mut self, height: u32) -> Self {
self.height = Some(height);
self
}
pub fn colored(mut self, colorful: bool) -> Self {
self.colored = colorful;
self
}
pub fn invert(mut self, invert: bool) -> Self {
self.invert = invert;
self
}
pub fn charset(mut self, charset: &'a [&'a str]) -> Self {
self.charset = charset;
self
}
}
impl Default for RenderOptions<'_> {
fn default() -> Self {
Self {
width: None,
height: None,
colored: false,
invert: false,
charset: charsets::DEFAULT,
}
}
}
pub trait Renderer<'a, R> {
fn new(resource: &'a R, options: &'a RenderOptions<'a>) -> Self;
fn render(&self, writer: &mut impl io::Write) -> io::Result<()>;
fn render_to(&self, writer: &mut String) -> io::Result<()>;
}