use {start, Handler};
pub struct Options<'a, H> {
pub(crate) html: &'a str,
pub(crate) width: usize,
pub(crate) height: usize,
pub(crate) fullscreen: bool,
pub(crate) handler: H,
pub(crate) minimum_size: Option<(usize, usize)>,
}
impl Options<'static, ()> {
pub fn new() -> Self {
Self {
html: "",
width: 640,
height: 480,
fullscreen: false,
handler: (),
minimum_size: None,
}
}
}
impl<'a, H> Options<'a, H> {
pub fn html<'aa>(self, html: &'aa str) -> Options<'aa, H> {
let Options { width, height, fullscreen, handler, minimum_size, .. } = self;
Options { html, width, height, fullscreen, handler, minimum_size }
}
pub fn size(self, width: usize, height: usize) -> Options<'a, H> {
let Options { html, fullscreen, handler, minimum_size, .. } = self;
Options { html, width, height, fullscreen, handler, minimum_size }
}
pub fn minimum_size(self, width: usize, height: usize) -> Options<'a, H> {
let minimum_size = Some((width, height));
let Options { html, width, height, fullscreen, handler, .. } = self;
Options { html, width, height, fullscreen, handler, minimum_size }
}
pub fn fullscreen(self, fullscreen: bool) -> Options<'a, H> {
let Options { html, width, height, handler, minimum_size, .. } = self;
Options { html, width, height, fullscreen, handler, minimum_size }
}
pub fn handler<HH>(self, handler: HH) -> Options<'a, HH> {
let Options { html, width, height, fullscreen, minimum_size, .. } = self;
Options { html, width, height, fullscreen, handler, minimum_size }
}
}
impl<'a, H: Handler> Options<'a, H> {
pub fn start(self) -> ! {
start(self)
}
}