Move ImfsEvent into its own module

This commit is contained in:
Lucien Greathouse
2019-10-01 10:44:35 -07:00
parent bcf4fea598
commit 1737da9c1f
6 changed files with 17 additions and 7 deletions

2
src/imfs/event.rs Normal file
View File

@@ -0,0 +1,2 @@
// TODO: Use our own event type instead of notify's.
pub type ImfsEvent = notify::DebouncedEvent;

View File

@@ -5,15 +5,14 @@ use std::{
use crossbeam_channel::Receiver;
use super::event::ImfsEvent;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum FileType {
File,
Directory,
}
// TODO: Use our own event type instead of notify's.
pub type ImfsEvent = notify::DebouncedEvent;
/// The generic interface that `Imfs` uses to lazily read files from the disk.
/// In tests, it's stubbed out to do different versions of absolutely nothing
/// depending on the test.

View File

@@ -9,7 +9,8 @@ use crate::path_map::PathMap;
use super::{
error::{FsError, FsResult},
fetcher::{FileType, ImfsEvent, ImfsFetcher},
event::ImfsEvent,
fetcher::{FileType, ImfsFetcher},
snapshot::ImfsSnapshot,
};
@@ -425,7 +426,7 @@ mod test {
use crossbeam_channel::Receiver;
use maplit::hashmap;
use super::super::{error::FsErrorKind, fetcher::ImfsEvent, noop_fetcher::NoopFetcher};
use super::super::{error::FsErrorKind, event::ImfsEvent, noop_fetcher::NoopFetcher};
#[test]
fn from_snapshot_file() {

View File

@@ -1,4 +1,5 @@
mod error;
mod event;
mod fetcher;
mod imfs;
mod noop_fetcher;
@@ -6,6 +7,7 @@ mod real_fetcher;
mod snapshot;
pub use error::*;
pub use event::*;
pub use fetcher::*;
pub use imfs::*;
pub use noop_fetcher::*;

View File

@@ -11,7 +11,10 @@ use std::{
use crossbeam_channel::Receiver;
use super::fetcher::{FileType, ImfsEvent, ImfsFetcher};
use super::{
event::ImfsEvent,
fetcher::{FileType, ImfsFetcher},
};
pub struct NoopFetcher;

View File

@@ -13,7 +13,10 @@ use crossbeam_channel::{unbounded, Receiver};
use jod_thread::JoinHandle;
use notify::{RecommendedWatcher, RecursiveMode, Watcher};
use super::fetcher::{FileType, ImfsEvent, ImfsFetcher};
use super::{
event::ImfsEvent,
fetcher::{FileType, ImfsFetcher},
};
/// Workaround to disable the file watcher for processes that don't need it,
/// since notify appears hang on to mpsc Sender objects too long, causing Rojo