|
|
@ -50,7 +50,7 @@ bitflags! {
|
|
|
|
/// Emmit delete events.
|
|
|
|
/// Emmit delete events.
|
|
|
|
const DELETE = 1<<2;
|
|
|
|
const DELETE = 1<<2;
|
|
|
|
|
|
|
|
|
|
|
|
/// Propagate events from children of `Map` datas
|
|
|
|
/// Propagate events from children of `Map` or `List` datas
|
|
|
|
const CHILD = 1<<3;
|
|
|
|
const CHILD = 1<<3;
|
|
|
|
|
|
|
|
|
|
|
|
/// Poke events are opaque events that are fired manually.
|
|
|
|
/// Poke events are opaque events that are fired manually.
|
|
|
@ -68,28 +68,45 @@ impl Default for HookMask
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
id_type!(pub HookID: "The ID of a hook, passed with the event when the hook is fired");
|
|
|
|
|
|
|
|
|
|
|
|
/// Fire events when something happens to this value.
|
|
|
|
/// Fire events when something happens to this value.
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
|
|
pub struct Hooks
|
|
|
|
pub struct Hooks
|
|
|
|
{
|
|
|
|
{
|
|
|
|
filter: HookMask,
|
|
|
|
filter: HookMask,
|
|
|
|
|
|
|
|
id: HookID,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl Default for Hooks
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
|
|
|
|
fn default() -> Self
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Self {
|
|
|
|
|
|
|
|
id: HookID::id_new(), // generate an id now, in case hooks are added later
|
|
|
|
|
|
|
|
filter: Default::default(), //default is to emit nothing ever
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// An event emitted from a matched `Hook`.
|
|
|
|
/// An event emitted from a matched `Hook`.
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash, Ord, PartialOrd)]
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash, Ord, PartialOrd)]
|
|
|
|
pub enum HookEvent
|
|
|
|
pub enum HookEventKind
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/// An opaque event type
|
|
|
|
/// An opaque event type that can only be fired manually.
|
|
|
|
Poke,
|
|
|
|
Poke,
|
|
|
|
|
|
|
|
|
|
|
|
Read,
|
|
|
|
Read,
|
|
|
|
Write,
|
|
|
|
Write,
|
|
|
|
Delete,
|
|
|
|
Delete,
|
|
|
|
|
|
|
|
/// An event propagated from a child of this element.
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// This only can happen with `Map` or `List` data kinds.
|
|
|
|
Child(Box<HookEvent>),
|
|
|
|
Child(Box<HookEvent>),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl Default for HookEvent
|
|
|
|
impl Default for HookEventKind
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#[inline]
|
|
|
|
#[inline]
|
|
|
|
fn default() -> Self
|
|
|
|
fn default() -> Self
|
|
|
@ -98,3 +115,11 @@ impl Default for HookEvent
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// An event emitted from a element value's `Hooks` object.
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash, Ord, PartialOrd)]
|
|
|
|
|
|
|
|
pub struct HookEvent
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
kind: HookEventKind,
|
|
|
|
|
|
|
|
/// Corresponds to the `id` field of the `Hooks` object this event was emitted from.
|
|
|
|
|
|
|
|
id: HookID,
|
|
|
|
|
|
|
|
}
|
|
|
|