mirror of
https://github.com/watchexec/watchexec.git
synced 2024-11-13 07:41:11 +01:00
Add paths() convenience iter on Event
This commit is contained in:
parent
8998c40746
commit
613fe24c64
1 changed files with 14 additions and 1 deletions
|
@ -6,7 +6,10 @@
|
|||
//! 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};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use crate::signal::Signal;
|
||||
|
||||
|
@ -37,3 +40,13 @@ pub enum Source {
|
|||
Os,
|
||||
Time,
|
||||
}
|
||||
|
||||
impl Event {
|
||||
/// Return all paths in the event's particulars.
|
||||
pub fn paths(&self) -> impl Iterator<Item = &Path> {
|
||||
self.particulars.iter().filter_map(|p| match p {
|
||||
Particle::Path(p) => Some(p.as_path()),
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue