Start on filter types
This commit is contained in:
parent
9e3c8c1f32
commit
6a55f5cc6d
|
@ -17,6 +17,15 @@ version = "1.0.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.7.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.12.1"
|
||||
|
@ -1424,6 +1433,8 @@ version = "1.5.4"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
]
|
||||
|
||||
|
@ -1974,6 +1985,7 @@ dependencies = [
|
|||
"miette",
|
||||
"notify",
|
||||
"once_cell",
|
||||
"regex",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tracing",
|
||||
|
|
|
@ -24,6 +24,7 @@ futures = "0.3.16"
|
|||
miette = "1.0.0-beta.1"
|
||||
notify = "5.0.0-pre.12"
|
||||
once_cell = "1.8.0"
|
||||
regex = "1.5.4"
|
||||
thiserror = "1.0.26"
|
||||
tracing = "0.1.26"
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ use tracing::{debug, error, trace, warn};
|
|||
|
||||
use crate::{
|
||||
error::RuntimeError,
|
||||
event::{Event, Tag, Source},
|
||||
event::{Event, Source, Tag},
|
||||
};
|
||||
|
||||
use super::Process;
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
use std::{collections::HashSet, path::PathBuf};
|
||||
|
||||
use regex::Regex;
|
||||
|
||||
use crate::event::Tag;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Filter {
|
||||
pub in_path: Option<PathBuf>,
|
||||
pub on: Tag,
|
||||
pub op: Op,
|
||||
pub pat: Pattern,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Op {
|
||||
Equal,
|
||||
NotEqual,
|
||||
Regex,
|
||||
Glob,
|
||||
Includes,
|
||||
Excludes,
|
||||
InSet,
|
||||
OutSet,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Pattern {
|
||||
Exact(String),
|
||||
Regex(Regex),
|
||||
Set(HashSet<String>),
|
||||
}
|
||||
|
||||
impl PartialEq<Self> for Pattern {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
match (self, other) {
|
||||
(Self::Exact(l), Self::Exact(r)) => l == r,
|
||||
(Self::Regex(l), Self::Regex(r)) => l.as_str() == r.as_str(),
|
||||
(Self::Set(l), Self::Set(r)) => l == r,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Eq for Pattern {}
|
|
@ -14,7 +14,7 @@ use tracing::{debug, error, trace};
|
|||
|
||||
use crate::{
|
||||
error::{CriticalError, RuntimeError},
|
||||
event::{Event, Tag, Source},
|
||||
event::{Event, Source, Tag},
|
||||
};
|
||||
|
||||
/// What kind of filesystem watcher to use.
|
||||
|
@ -249,10 +249,7 @@ fn process_event(
|
|||
metadata.insert("notify-backend".to_string(), vec![src.to_string()]);
|
||||
}
|
||||
|
||||
let ev = Event {
|
||||
tags,
|
||||
metadata,
|
||||
};
|
||||
let ev = Event { tags, metadata };
|
||||
|
||||
trace!(event = ?ev, "processed notify event into watchexec event");
|
||||
n_events
|
||||
|
|
|
@ -90,6 +90,7 @@ pub mod action;
|
|||
pub mod command;
|
||||
pub mod error;
|
||||
pub mod event;
|
||||
pub mod filter;
|
||||
pub mod fs;
|
||||
pub mod signal;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ use tracing::{debug, trace};
|
|||
|
||||
use crate::{
|
||||
error::{CriticalError, RuntimeError},
|
||||
event::{Event, Tag, Source},
|
||||
event::{Event, Source, Tag},
|
||||
};
|
||||
|
||||
/// A notification sent to the main (watchexec) process.
|
||||
|
|
Loading…
Reference in New Issue