|
|
@ -1,9 +1,10 @@
|
|
|
|
//! When events happen to datamaps
|
|
|
|
//! When events happen to datamaps
|
|
|
|
use super::*;
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
use bitflags::bitflags;
|
|
|
|
|
|
|
|
|
|
|
|
/// What happened in the event
|
|
|
|
/// What happened in the in-band event
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
|
|
pub enum EventKind
|
|
|
|
pub enum InBandEventKind
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Created,
|
|
|
|
Created,
|
|
|
|
Modified,
|
|
|
|
Modified,
|
|
|
@ -16,13 +17,84 @@ pub enum EventKind
|
|
|
|
Comment(String),
|
|
|
|
Comment(String),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// An event that happened to a data entry
|
|
|
|
/// An event that happened to a data entry that is then stored in its metadata.
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
/// # Note
|
|
|
|
|
|
|
|
/// Not to be confused with `HookEvent`s
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
|
|
pub struct Event
|
|
|
|
pub struct InBandEvent
|
|
|
|
{
|
|
|
|
{
|
|
|
|
who: Option<user::UserID>,
|
|
|
|
who: Option<user::UserID>,
|
|
|
|
what: EventKind,
|
|
|
|
what: InBandEventKind,
|
|
|
|
when: u64,
|
|
|
|
when: u64,
|
|
|
|
|
|
|
|
|
|
|
|
signed: Option<cryptohelpers::rsa::Signature>,
|
|
|
|
signed: Option<cryptohelpers::rsa::Signature>,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bitflags! {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Kind of events that should emmit for a hook
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
|
|
|
|
|
|
struct HookMask: u16
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/// Filter all events. None are emiited.
|
|
|
|
|
|
|
|
const NONE = 0;
|
|
|
|
|
|
|
|
/// Mask any event, any kind is emitted.
|
|
|
|
|
|
|
|
const ANY = !0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Emmit read events.
|
|
|
|
|
|
|
|
const READ = 1<<0;
|
|
|
|
|
|
|
|
/// Emmit write events.
|
|
|
|
|
|
|
|
const WRITE = 1<<1;
|
|
|
|
|
|
|
|
/// Emmit delete events.
|
|
|
|
|
|
|
|
const DELETE = 1<<2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Propagate events from children of `Map` datas
|
|
|
|
|
|
|
|
const CHILD = 1<<3;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Poke events are opaque events that are fired manually.
|
|
|
|
|
|
|
|
const POKE = 1<<4;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl Default for HookMask
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
#[inline(always)]
|
|
|
|
|
|
|
|
fn default() -> Self
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Self::NONE
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Fire events when something happens to this value.
|
|
|
|
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
|
|
|
|
|
|
pub struct Hooks
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
filter: HookMask,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// An event emitted from a matched `Hook`.
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash, Ord, PartialOrd)]
|
|
|
|
|
|
|
|
pub enum HookEvent
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/// An opaque event type
|
|
|
|
|
|
|
|
Poke,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Read,
|
|
|
|
|
|
|
|
Write,
|
|
|
|
|
|
|
|
Delete,
|
|
|
|
|
|
|
|
Child(Box<HookEvent>),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl Default for HookEvent
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
|
|
|
|
fn default() -> Self
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Self::Poke
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|