#![deny(missing_docs)]
#![allow(clippy::module_inception)]
mod app;
mod builder;
mod command;
mod delegate;
mod request;
pub use app::*;
pub use builder::*;
pub use command::*;
pub use delegate::*;
pub use request::*;
use ori_core::view::{AnyView, BoxedView};
pub type UiBuilder<T> = Box<dyn FnMut(&mut T) -> BoxedView<T>>;
pub trait IntoUiBuilder<V, P> {
type Data;
fn into_ui_builder(self) -> UiBuilder<Self::Data>;
}
impl<T, V, F> IntoUiBuilder<V, &mut T> for F
where
F: FnMut(&mut T) -> V + 'static,
V: AnyView<T> + 'static,
{
type Data = T;
fn into_ui_builder(mut self) -> UiBuilder<Self::Data> {
Box::new(move |data| Box::new(self(data)))
}
}
impl<T, V, F> IntoUiBuilder<V, (T,)> for F
where
F: FnMut() -> V + 'static,
V: AnyView<T> + 'static,
{
type Data = T;
fn into_ui_builder(mut self) -> UiBuilder<Self::Data> {
Box::new(move |_| Box::new(self()))
}
}