mirror of
https://github.com/bevyengine/bevy
synced 2025-01-12 13:18:55 +00:00
54ff7aaa1e
# Objective notify 5.0.0-pre.11 breaks the interface again, but apparently in a way that's similar to how it used to be ## Solution Bump `bevy_asset` dependency on notify to `5.0.0-pre.11` and fix the errors that crop up. It looks like `pre.11` was mentioned in #2528 by @mockersf but there's no mention of why `pre.10` was chosen ultimately.
27 lines
917 B
Rust
27 lines
917 B
Rust
use crossbeam_channel::Receiver;
|
|
use notify::{Event, RecommendedWatcher, RecursiveMode, Result, Watcher};
|
|
use std::path::Path;
|
|
|
|
/// Watches for changes to assets on the filesystem. This is used by the `AssetServer` to reload
|
|
/// them
|
|
pub struct FilesystemWatcher {
|
|
pub watcher: RecommendedWatcher,
|
|
pub receiver: Receiver<Result<Event>>,
|
|
}
|
|
|
|
impl Default for FilesystemWatcher {
|
|
fn default() -> Self {
|
|
let (sender, receiver) = crossbeam_channel::unbounded();
|
|
let watcher: RecommendedWatcher = RecommendedWatcher::new(move |res| {
|
|
sender.send(res).expect("Watch event send failure.");
|
|
})
|
|
.expect("Failed to create filesystem watcher.");
|
|
FilesystemWatcher { watcher, receiver }
|
|
}
|
|
}
|
|
|
|
impl FilesystemWatcher {
|
|
pub fn watch<P: AsRef<Path>>(&mut self, path: P) -> Result<()> {
|
|
self.watcher.watch(path.as_ref(), RecursiveMode::Recursive)
|
|
}
|
|
}
|