watchexec/lib/src/event.rs

38 lines
936 B
Rust
Raw Normal View History

2021-08-16 11:49:12 +02:00
//! Fundamentally, events in watchexec have three purposes:
//!
//! 1. To trigger the launch, restart, or other interruption of a process;
//! 2. To be filtered upon according to whatever set of criteria is desired;
//! 3. To carry information about what caused the event, which may be provided to the process.
use std::{collections::HashMap, path::PathBuf};
2021-08-17 11:41:13 +02:00
use crate::signal::Signal;
2021-08-16 11:49:12 +02:00
/// An event, as far as watchexec cares about.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Event {
pub particulars: Vec<Particle>,
pub metadata: HashMap<String, Vec<String>>,
}
/// Something which can be used to filter an event.
#[derive(Clone, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum Particle {
Path(PathBuf),
Source(Source),
Process(u32),
2021-08-17 11:41:13 +02:00
Signal(Signal),
2021-08-16 11:49:12 +02:00
}
/// The general origin of the event.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum Source {
Filesystem,
Keyboard,
Mouse,
2021-08-17 11:41:13 +02:00
Os,
2021-08-16 11:49:12 +02:00
Time,
}