45 lines
970 B
Rust
45 lines
970 B
Rust
mod ctx;
|
|
mod manager;
|
|
mod rsc;
|
|
|
|
pub use ctx::*;
|
|
pub use manager::*;
|
|
pub use rsc::*;
|
|
|
|
pub trait Event: Sized + 'static + Clone {
|
|
type Data<'a> = ();
|
|
type State: Default = ();
|
|
#[allow(unused_variables)]
|
|
fn should_run(&self, data: &mut Self::Data<'_>) -> bool {
|
|
true
|
|
}
|
|
}
|
|
|
|
pub trait EventLike {
|
|
type Event: Event;
|
|
fn into_event(self) -> Self::Event;
|
|
}
|
|
|
|
impl<E: Event> EventLike for E {
|
|
type Event = Self;
|
|
|
|
fn into_event(self) -> Self::Event {
|
|
self
|
|
}
|
|
}
|
|
|
|
pub trait EventFn<Rsc: HasEvents, Data>: Fn(&mut EventCtx<Rsc, Data>, &mut Rsc) + 'static {}
|
|
impl<Rsc: HasEvents, F: Fn(&mut EventCtx<Rsc, Data>, &mut Rsc) + 'static, Data> EventFn<Rsc, Data>
|
|
for F
|
|
{
|
|
}
|
|
|
|
pub trait WidgetEventFn<Rsc: HasEvents, Data, W: ?Sized>:
|
|
Fn(&mut EventIdCtx<Rsc, Data, W>, &mut Rsc) + 'static
|
|
{
|
|
}
|
|
impl<Rsc: HasEvents, F: Fn(&mut EventIdCtx<Rsc, Data, W>, &mut Rsc) + 'static, Data, W: ?Sized>
|
|
WidgetEventFn<Rsc, Data, W> for F
|
|
{
|
|
}
|