diff --git a/lib/src/filter.rs b/lib/src/filter.rs index e1437dd..431100a 100644 --- a/lib/src/filter.rs +++ b/lib/src/filter.rs @@ -1,61 +1,5 @@ -use std::{collections::HashSet, path::PathBuf}; - -use globset::Glob; -use regex::Regex; +#[doc(inline)] +pub use types::*; mod parse; - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct Filter { - pub in_path: Option, - pub on: Matcher, - pub op: Op, - pub pat: Pattern, -} - -#[derive(Clone, Copy, Debug, Eq, PartialEq)] -#[non_exhaustive] -pub enum Matcher { - Tag, - Path, - FileEventKind, - Source, - Process, - Signal, - ProcessCompletion, -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[non_exhaustive] -pub enum Op { - Auto, // = - Equal, // == - NotEqual, // != - Regex, // ~= - Glob, // *= - InSet, // := - NotInSet, // :! -} - -#[derive(Debug, Clone)] -#[non_exhaustive] -pub enum Pattern { - Exact(String), - Regex(Regex), - Glob(Glob), - Set(HashSet), -} - -impl PartialEq 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::Glob(l), Self::Glob(r)) => l == r, - (Self::Set(l), Self::Set(r)) => l == r, - _ => false, - } - } -} - -impl Eq for Pattern {} +mod types; diff --git a/lib/src/filter/types.rs b/lib/src/filter/types.rs new file mode 100644 index 0000000..da1ce73 --- /dev/null +++ b/lib/src/filter/types.rs @@ -0,0 +1,59 @@ +use std::{collections::HashSet, path::PathBuf}; + +use globset::Glob; +use regex::Regex; + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Filter { + pub in_path: Option, + pub on: Matcher, + pub op: Op, + pub pat: Pattern, +} + +#[derive(Clone, Copy, Debug, Eq, PartialEq)] +#[non_exhaustive] +pub enum Matcher { + Tag, + Path, + FileEventKind, + Source, + Process, + Signal, + ProcessCompletion, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum Op { + Auto, // = + Equal, // == + NotEqual, // != + Regex, // ~= + Glob, // *= + InSet, // := + NotInSet, // :! +} + +#[derive(Debug, Clone)] +#[non_exhaustive] +pub enum Pattern { + Exact(String), + Regex(Regex), + Glob(Glob), + Set(HashSet), +} + +impl PartialEq 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::Glob(l), Self::Glob(r)) => l == r, + (Self::Set(l), Self::Set(r)) => l == r, + _ => false, + } + } +} + +impl Eq for Pattern {}