use crate::{ActiveAppEnv, ModifyView, Shell};
use async_trait::async_trait;
use bytes::BytesMut;
use file_format::FileFormat;
use std::borrow::Cow;
pub type StaticCowStr = Cow<'static, str>;
pub type CowStr<'p> = Cow<'p, str>;
pub type StaticStr = &'static str;
#[async_trait::async_trait]
pub trait Puppeteer {
fn window_size() -> f32 {
90f32 / 100f32
}
fn splash_window_size() -> f32 {
90f32 / 100f32
}
fn shell() -> Shell;
async fn init(app_env: &ActiveAppEnv) -> ModifyView;
fn splashscreen() -> ModifyView;
fn parse(message: &str) -> Self;
async fn event_handler(&mut self, app_env: &ActiveAppEnv) -> ModifyView;
async fn error_handler(error: impl std::error::Error + Send) -> ModifyView;
}
#[async_trait]
pub trait UiPaint {
fn to_native(&self) {}
fn to_html(&self) -> Cow<str>;
}
impl core::fmt::Debug for dyn UiPaint {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "UiPaint")
}
}
impl UiPaint for &String {
fn to_html(&self) -> Cow<str> {
Cow::Borrowed("") + Cow::Owned(self.to_string())
}
}
impl UiPaint for Cow<'_, str> {
fn to_html(&self) -> Cow<str> {
self.clone()
}
}
impl UiPaint for &str {
fn to_html(&self) -> Cow<str> {
Cow::Borrowed(self)
}
}
pub trait AssetProperties {
fn name(&self) -> Cow<str>;
fn format(&self) -> FileFormat;
fn bytes(&self) -> &BytesMut;
fn base64(&self) -> Cow<str>;
fn hash(&self) -> blake3::Hash;
}
pub trait StaticAssetProperties {
fn name(&self) -> &'static str;
fn format(&self) -> FileFormat;
fn bytes(&self) -> &'static [u8];
fn base64(&self) -> Cow<str>;
fn hash(&self) -> blake3::Hash;
}