Debian Codegraph @

src/lib.rs

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 //! Opportunistic dirty file tracker
2 //!
3 //! This library provides a simple way to track dirty files in a directory.
4 //! It uses the `notify` crate to watch for file system events and keep track
5 //! of the files that have been modified.
6 //!
7 //! If the underlying file system does not support watching for file system events, or if there are
8 //! too many files to watch, the tracker will simply give up and return `State::Unknown`.
9 //!
10 //! # Example
11 //! ```rust
12 //! use dirty_tracker::{State, DirtyTracker};
13 //!
14 //! let td = tempfile::tempdir().unwrap();
15 //!
16 //! let mut tracker = DirtyTracker::new(td.path()).unwrap();
17 //! assert_eq!(tracker.state(), State::Clean);
18 //! assert!(tracker.paths().unwrap().is_empty());
19 //!
20 //! // Modify a file in the directory.
21 //! std::fs::write(td.path().join("file"), b"hello").unwrap();
22 //!
23 //! assert_eq!(tracker.state(), State::Dirty);
24 //! assert_eq!(tracker.paths(), Some(&maplit::hashset![td.path().join("file")]));
25 //! ```
26
27 use notifyrust-analyzer cargo notify 8.2.0 crate/::{Eventrust-analyzer cargo notify-types 2.1.0 event/Event#, EventKindrust-analyzer cargo notify-types 2.1.0 event/EventKind#, RecommendedWatcherrust-analyzer cargo notify 8.2.0 RecommendedWatcher#, RecursiveModerust-analyzer cargo notify 8.2.0 config/RecursiveMode#, Watcherrust-analyzer cargo notify 8.2.0 Watcher#};
28 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#;
29 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::{Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#, PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#};
30 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::mpscrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/mpsc/::{channelrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/mpsc/channel()., Receiverrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/mpsc/Receiver#, RecvErrorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/mpsc/RecvError#, RecvTimeoutErrorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/mpsc/RecvTimeoutError#};
31
32 /// The tracker object.
33 ///
34 /// This object keeps track of the dirty files in a directory.
35 ///
36 /// The tracker is created with a path to a directory. It will watch for file
37 /// system events in that directory and keep track of the files that have been
38 /// modified.
39 ///
40 /// The tracker can be in one of three states:
41 /// - Clean: No files have been modified.
42 /// - Dirty: Some files have been modified.
43 /// - Unknown: The tracker is in an unknown state. This can happen if the
44 /// tracker has missed some events, or if the underlying file system is
45 /// behaving in an unexpected way.
46 pub struct DirtyTrackerrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker# {
47 pathrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#path.: PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#,
48 rxrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#rx.: Receiverrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/mpsc/Receiver#<notifyrust-analyzer cargo notify 8.2.0 crate/::Resultrust-analyzer cargo notify 8.2.0 error/Result#<Eventrust-analyzer cargo notify-types 2.1.0 event/Event#>>,
49 pathsrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#paths.: HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#<PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#>,
50 createdrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#created.: HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#<PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#>,
51 need_rescanrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#need_rescan.: bool,
52 #[allow(dead_code)]
53 watcherrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#watcher.: RecommendedWatcherrust-analyzer cargo notify 8.2.0 RecommendedWatcher#,
54 }
55
56 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)]
57 pub enum Staterust-analyzer cargo dirty-tracker 0.3.0 State# {
58 Cleanrust-analyzer cargo dirty-tracker 0.3.0 State#Clean#,
59 Dirtyrust-analyzer cargo dirty-tracker 0.3.0 State#Dirty#,
60 Unknownrust-analyzer cargo dirty-tracker 0.3.0 State#Unknown#,
61 }
62
63 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
64 pub enum ProcessErrorrust-analyzer cargo dirty-tracker 0.3.0 ProcessError# {
65 Timeoutrust-analyzer cargo dirty-tracker 0.3.0 ProcessError#Timeout#(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#),
66 Disconnectedrust-analyzer cargo dirty-tracker 0.3.0 ProcessError#Disconnected#,
67 }
68
69 impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for ProcessErrorrust-analyzer cargo dirty-tracker 0.3.0 ProcessError# {
70 fn fmtrust-analyzer cargo dirty-tracker 0.3.0 impl#[ProcessError][Display]fmt().(&self, f: &mut stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
71 match self {
72 ProcessErrorrust-analyzer cargo dirty-tracker 0.3.0 ProcessError#::Timeoutrust-analyzer cargo dirty-tracker 0.3.0 ProcessError#Timeout#(timeout) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "Timeout: {:?}", timeout),
73 ProcessErrorrust-analyzer cargo dirty-tracker 0.3.0 ProcessError#::Disconnectedrust-analyzer cargo dirty-tracker 0.3.0 ProcessError#Disconnected# => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "Disconnected"),
74 }
75 }
76 }
77
78 impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for ProcessErrorrust-analyzer cargo dirty-tracker 0.3.0 ProcessError# {}
79
80 impl DirtyTrackerrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker# {
81 /// Create a new tracker object.
82 ///
83 /// # Arguments
84 /// * `path` - The path to the directory to watch.
85 ///
86 /// # Returns
87 /// A new `DirtyTracker` object.
88 pub fn newrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]new().(path: &Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#) -> notifyrust-analyzer cargo notify 8.2.0 crate/::Resultrust-analyzer cargo notify 8.2.0 error/Result#<Selfrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]> {
89 // Create a channel to receive the events.
90 let (tx, rx) = channelrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/mpsc/channel().();
91
92 let config = notifyrust-analyzer cargo notify 8.2.0 crate/::Configrust-analyzer cargo notify 8.2.0 config/Config#::defaultrust-analyzer cargo notify 8.2.0 config/impl#[Config][Default]default().();
93
94 // Create a watcher object.
95 let mut watcher: RecommendedWatcherrust-analyzer cargo notify 8.2.0 RecommendedWatcher# = notifyrust-analyzer cargo notify 8.2.0 crate/::RecommendedWatcherrust-analyzer cargo notify 8.2.0 RecommendedWatcher#::newrust-analyzer cargo notify 8.2.0 inotify/impl#[INotifyWatcher][Watcher]new().(tx, config)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
96
97 // TODO: Refuse to work with watchers that are low-performance.
98
99 // Add a path to be watched. All files and directories at that path and below will be monitored for changes.
100 watcher.watchrust-analyzer cargo notify 8.2.0 inotify/impl#[INotifyWatcher][Watcher]watch().(path, RecursiveModerust-analyzer cargo notify 8.2.0 config/RecursiveMode#::Recursiverust-analyzer cargo notify 8.2.0 config/RecursiveMode#Recursive#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
101
102 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(DirtyTrackerrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker# {
103 pathrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#path.: path.to_path_bufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_path_buf().(),
104 rxrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#rx.,
105 pathsrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#paths.: HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T>`]new().(),
106 createdrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#created.: HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T>`]new().(),
107 need_rescanrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#need_rescan.: false,
108 watcherrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#watcher.,
109 })
110 }
111
112 /// Mark all files as clean.
113 ///
114 /// Note that this can race with file modifications, so it's only safe
115 /// if you're sure that no modifications are happening.
116 pub fn mark_cleanrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]mark_clean().(&mut self) {
117 let _ = self.process_pendingrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]process_pending().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
118 self.need_rescanrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#need_rescan. = false;
119 self.pathsrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#paths..clearrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]clear().();
120 self.createdrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#created..clearrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]clear().();
121 }
122
123 /// Returns true if there are dirty files.
124 #[deprecated(since = "0.2.0", note = "Use state() instead")]
125 pub fn is_dirtyrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]is_dirty().(&mut self) -> bool {
126 self.staterust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]state().() rust-analyzer cargo dirty-tracker 0.3.0 impl#[State][`PartialEq<Self>`]eq().==rust-analyzer cargo dirty-tracker 0.3.0 impl#[State][`PartialEq<Self>`]eq(). rust-analyzer cargo dirty-tracker 0.3.0 impl#[State][`PartialEq<Self>`]eq().Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Dirtyrust-analyzer cargo dirty-tracker 0.3.0 State#Dirty#
127 }
128
129 /// Returns the state of the tracker.
130 pub fn staterust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]state().(&mut self) -> Staterust-analyzer cargo dirty-tracker 0.3.0 State# {
131 if self.process_pendingrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]process_pending().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().() {
132 return Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Unknownrust-analyzer cargo dirty-tracker 0.3.0 State#Unknown#;
133 }
134 if self.need_rescanrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#need_rescan. {
135 Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Unknownrust-analyzer cargo dirty-tracker 0.3.0 State#Unknown#
136 } else if self.pathsrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#paths..is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().() {
137 Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Cleanrust-analyzer cargo dirty-tracker 0.3.0 State#Clean#
138 } else {
139 Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Dirtyrust-analyzer cargo dirty-tracker 0.3.0 State#Dirty#
140 }
141 }
142
143 /// Returns the paths of the dirty files.
144 ///
145 /// If the tracker is in an unknown state, this will return None.
146 pub fn pathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]paths().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#<PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#>> {
147 if self.process_pendingrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]process_pending().(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#).is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().() {
148 return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
149 }
150 if self.need_rescanrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#need_rescan. {
151 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
152 } else {
153 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&self.pathsrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#paths.)
154 }
155 }
156
157 /// Returns the relative paths of the dirty files.
158 ///
159 /// If the tracker is in an unknown state, this will return None.
160 pub fn relpathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]relpaths().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#<&Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#>> {
161 let path = self.pathrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#path..clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][Clone]clone().();
162 self.pathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]paths().().as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_mut().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|paths| {
163 paths
164 .iterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]iter().()
165 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|p| p.strip_prefixrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]strip_prefix().(&path).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().())
166 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
167 })
168 }
169
170 fn process_pending_eventrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]process_pending_event().(&mut self, event: Eventrust-analyzer cargo notify-types 2.1.0 event/Event#) {
171 if event.need_rescanrust-analyzer cargo notify-types 2.1.0 event/impl#[Event]need_rescan().() {
172 self.need_rescanrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#need_rescan. = true;
173 }
174 match event {
175 Eventrust-analyzer cargo notify-types 2.1.0 event/Event# {
176 kindrust-analyzer cargo notify-types 2.1.0 event/Event#kind.: EventKindrust-analyzer cargo notify-types 2.1.0 event/EventKind#::Createrust-analyzer cargo notify-types 2.1.0 event/EventKind#Create#(_),
177 pathsrust-analyzer cargo notify-types 2.1.0 event/Event#paths.,
178 ..
179 } => {
180 for path in paths {
181 self.createdrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#created..insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(path.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][Clone]clone().());
182 self.pathsrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#paths..insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(path);
183 }
184 }
185 Eventrust-analyzer cargo notify-types 2.1.0 event/Event# {
186 kindrust-analyzer cargo notify-types 2.1.0 event/Event#kind.: EventKindrust-analyzer cargo notify-types 2.1.0 event/EventKind#::Modifyrust-analyzer cargo notify-types 2.1.0 event/EventKind#Modify#(_),
187 pathsrust-analyzer cargo notify-types 2.1.0 event/Event#paths.,
188 ..
189 } => {
190 for path in paths {
191 self.pathsrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#paths..insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(path);
192 }
193 }
194 Eventrust-analyzer cargo notify-types 2.1.0 event/Event# {
195 kindrust-analyzer cargo notify-types 2.1.0 event/Event#kind.: EventKindrust-analyzer cargo notify-types 2.1.0 event/EventKind#::Removerust-analyzer cargo notify-types 2.1.0 event/EventKind#Remove#(_),
196 pathsrust-analyzer cargo notify-types 2.1.0 event/Event#paths.,
197 ..
198 } => {
199 for path in paths {
200 if self.createdrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#created..containsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]contains().(&path) {
201 self.pathsrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#paths..removerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]remove().(&path);
202 self.createdrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#created..removerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]remove().(&path);
203 } else {
204 self.pathsrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#paths..insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(path.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][Clone]clone().());
205 }
206 }
207 }
208 _ => {}
209 }
210 }
211
212 fn process_pendingrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]process_pending().(
213 &mut self,
214 timeout: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#>,
215 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), ProcessErrorrust-analyzer cargo dirty-tracker 0.3.0 ProcessError#> {
216 // Make a sentinel change to ensure that we process all pending events.
217
218 // We do this by creating a dummy file and then deleting it
219 // immediately.
220 //
221 // This is a bit of a hack, but it's the simplest way to ensure
222 // that we process all pending events.
223 //
224 // We can't just wait for a timeout, because we might miss events - and it would be
225 // difficult to determine the correct timeout value. Performance is one of the main
226 // reasons for using this library, so we don't want to wait for a long time.
227 let mut dummy = tempfilerust-analyzer cargo tempfile 3.27.0 crate/::NamedTempFilerust-analyzer cargo tempfile 3.27.0 file/NamedTempFile#::new_inrust-analyzer cargo tempfile 3.27.0 file/impl#[NamedTempFile]new_in().(&self.pathrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#path.).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
228 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#;
229 dummy.write_allrust-analyzer cargo tempfile 3.27.0 file/impl#[`NamedTempFile<F>`][Write]write_all().(b"dummy").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
230 let dummy_path = dummy.pathrust-analyzer cargo tempfile 3.27.0 file/impl#[`NamedTempFile<F>`]path().().to_path_bufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_path_buf().();
231 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(dummy);
232
233 let is_sentinel_delete_event = |event: &notifyrust-analyzer cargo notify 8.2.0 crate/::Eventrust-analyzer cargo notify-types 2.1.0 event/Event#| {
234 matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(
235 event.kindrust-analyzer cargo notify-types 2.1.0 event/Event#kind.,
236 EventKindrust-analyzer cargo notify-types 2.1.0 event/EventKind#::Removerust-analyzer cargo notify-types 2.1.0 event/EventKind#Remove#(_) if event.pathsrust-analyzer cargo notify-types 2.1.0 event/Event#paths..iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|p| p == &dummy_path)
237 )
238 };
239
240 // Process all pending events.
241 loop {
242 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(timeout) = timeout {
243 match self.rxrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#rx..recv_timeoutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/mpsc/impl#[`Receiver<T>`]recv_timeout().(timeout) {
244 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(event)) => {
245 if is_sentinel_delete_event(&event) {
246 self.process_pending_eventrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]process_pending_event().(event);
247 break;
248 } else {
249 self.process_pending_eventrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]process_pending_event().(event)
250 }
251 }
252 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e)) => {
253 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Error receiving event: {:?}", e);
254 }
255 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(RecvTimeoutErrorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/mpsc/RecvTimeoutError#::Timeoutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/mpsc/RecvTimeoutError#Timeout#) => {
256 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ProcessErrorrust-analyzer cargo dirty-tracker 0.3.0 ProcessError#::Timeoutrust-analyzer cargo dirty-tracker 0.3.0 ProcessError#Timeout#(timeout));
257 }
258 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(RecvTimeoutErrorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/mpsc/RecvTimeoutError#::Disconnectedrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/mpsc/RecvTimeoutError#Disconnected#) => {
259 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ProcessErrorrust-analyzer cargo dirty-tracker 0.3.0 ProcessError#::Disconnectedrust-analyzer cargo dirty-tracker 0.3.0 ProcessError#Disconnected#);
260 }
261 }
262 } else {
263 match self.rxrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#rx..recvrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/mpsc/impl#[`Receiver<T>`]recv().() {
264 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(event)) => {
265 if is_sentinel_delete_event(&event) {
266 self.process_pending_eventrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]process_pending_event().(event);
267 break;
268 } else {
269 self.process_pending_eventrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]process_pending_event().(event)
270 }
271 }
272 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e)) => {
273 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Error receiving event: {:?}", e);
274 }
275 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(RecvErrorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/mpsc/RecvError#) => {
276 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ProcessErrorrust-analyzer cargo dirty-tracker 0.3.0 ProcessError#::Disconnectedrust-analyzer cargo dirty-tracker 0.3.0 ProcessError#Disconnected#);
277 }
278 }
279 }
280 }
281
282 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
283 }
284 }
285
286 #[cfg(test)]
287 mod testsrust-analyzer cargo dirty-tracker 0.3.0 tests/ {
288 use superrust-analyzer cargo dirty-tracker 0.3.0 crate/::*;
289 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#;
290 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#;
291 use tempfilerust-analyzer cargo tempfile 3.27.0 crate/::tempdirrust-analyzer cargo tempfile 3.27.0 dir/tempdir().;
292
293 fn wait_forrust-analyzer cargo dirty-tracker 0.3.0 tests/wait_for().(
294 tracker: &mut DirtyTrackerrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#,
295 expected_paths: &HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#<PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#>,
296 expected_state: Staterust-analyzer cargo dirty-tracker 0.3.0 State#,
297 ) {
298 let state = tracker.staterust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]state().();
299 let paths = tracker.pathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]paths().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`][Clone]clone().();
300 if state rust-analyzer cargo dirty-tracker 0.3.0 impl#[State][`PartialEq<Self>`]eq().==rust-analyzer cargo dirty-tracker 0.3.0 impl#[State][`PartialEq<Self>`]eq(). rust-analyzer cargo dirty-tracker 0.3.0 impl#[State][`PartialEq<Self>`]eq().Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Unknownrust-analyzer cargo dirty-tracker 0.3.0 State#Unknown# {
301 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Unexpected unknown state");
302 }
303 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(state, expected_state);
304 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(paths, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().expected_paths);
305 }
306
307 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
308 fn test_no_changesrust-analyzer cargo dirty-tracker 0.3.0 tests/test_no_changes().() {
309 let dir = tempdirrust-analyzer cargo tempfile 3.27.0 dir/tempdir().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
310 let mut tracker = DirtyTrackerrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#::newrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]new().(dir.pathrust-analyzer cargo tempfile 3.27.0 dir/impl#[TempDir]path().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
311 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.staterust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]state().(), Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Cleanrust-analyzer cargo dirty-tracker 0.3.0 State#Clean#);
312 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(tracker.pathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]paths().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().());
313
314 wait_forrust-analyzer cargo dirty-tracker 0.3.0 tests/wait_for().(&mut tracker, &maplitrust-analyzer cargo maplit 1.0.2 crate/::hashsetrust-analyzer cargo maplit 1.0.2 hashset!![], Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Cleanrust-analyzer cargo dirty-tracker 0.3.0 State#Clean#);
315
316 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.pathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]paths().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&maplitrust-analyzer cargo maplit 1.0.2 crate/::hashsetrust-analyzer cargo maplit 1.0.2 hashset!![]));
317 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.staterust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]state().(), Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Cleanrust-analyzer cargo dirty-tracker 0.3.0 State#Clean#);
318 }
319
320 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
321 fn test_simple_createrust-analyzer cargo dirty-tracker 0.3.0 tests/test_simple_create().() {
322 let dir = tempdirrust-analyzer cargo tempfile 3.27.0 dir/tempdir().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
323 let mut tracker = DirtyTrackerrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#::newrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]new().(dir.pathrust-analyzer cargo tempfile 3.27.0 dir/impl#[TempDir]path().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
324 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.staterust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]state().(), Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Cleanrust-analyzer cargo dirty-tracker 0.3.0 State#Clean#);
325 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(tracker.pathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]paths().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().());
326
327 let file = dir.pathrust-analyzer cargo tempfile 3.27.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("file");
328 let mut f = Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::createrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]create().(&file).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
329 f.write_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#write_all().(b"hello").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
330 f.sync_allrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]sync_all().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
331 wait_forrust-analyzer cargo dirty-tracker 0.3.0 tests/wait_for().(&mut tracker, &maplitrust-analyzer cargo maplit 1.0.2 crate/::hashsetrust-analyzer cargo maplit 1.0.2 hashset!![file.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][Clone]clone().()], Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Dirtyrust-analyzer cargo dirty-tracker 0.3.0 State#Dirty#);
332 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.pathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]paths().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&maplitrust-analyzer cargo maplit 1.0.2 crate/::hashsetrust-analyzer cargo maplit 1.0.2 hashset!![file.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][Clone]clone().()]));
333 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
334 tracker.relpathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]relpaths().(),
335 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(maplitrust-analyzer cargo maplit 1.0.2 crate/::hashsetrust-analyzer cargo maplit 1.0.2 hashset!![Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]new().("file")])
336 );
337 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.staterust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]state().(), Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Dirtyrust-analyzer cargo dirty-tracker 0.3.0 State#Dirty#);
338 }
339
340 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
341 fn test_simple_modifyrust-analyzer cargo dirty-tracker 0.3.0 tests/test_simple_modify().() {
342 let dir = tempdirrust-analyzer cargo tempfile 3.27.0 dir/tempdir().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
343
344 let file = dir.pathrust-analyzer cargo tempfile 3.27.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("file");
345 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/write().(&file, b"hello").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
346
347 let mut tracker = DirtyTrackerrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#::newrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]new().(dir.pathrust-analyzer cargo tempfile 3.27.0 dir/impl#[TempDir]path().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
348 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.staterust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]state().(), Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Cleanrust-analyzer cargo dirty-tracker 0.3.0 State#Clean#);
349 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(tracker.pathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]paths().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().());
350
351 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/write().(&file, b"world").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
352
353 wait_forrust-analyzer cargo dirty-tracker 0.3.0 tests/wait_for().(&mut tracker, &maplitrust-analyzer cargo maplit 1.0.2 crate/::hashsetrust-analyzer cargo maplit 1.0.2 hashset!![file.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][Clone]clone().()], Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Dirtyrust-analyzer cargo dirty-tracker 0.3.0 State#Dirty#);
354 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.pathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]paths().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&maplitrust-analyzer cargo maplit 1.0.2 crate/::hashsetrust-analyzer cargo maplit 1.0.2 hashset!![file.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][Clone]clone().()]));
355 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
356 tracker.relpathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]relpaths().(),
357 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(maplitrust-analyzer cargo maplit 1.0.2 crate/::hashsetrust-analyzer cargo maplit 1.0.2 hashset!![Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]new().("file")])
358 );
359 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.staterust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]state().(), Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Dirtyrust-analyzer cargo dirty-tracker 0.3.0 State#Dirty#);
360 }
361
362 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
363 fn test_deleterust-analyzer cargo dirty-tracker 0.3.0 tests/test_delete().() {
364 let dir = tempdirrust-analyzer cargo tempfile 3.27.0 dir/tempdir().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
365
366 let file = dir.pathrust-analyzer cargo tempfile 3.27.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("file");
367 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/write().(&file, b"hello").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
368
369 let mut tracker = DirtyTrackerrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#::newrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]new().(dir.pathrust-analyzer cargo tempfile 3.27.0 dir/impl#[TempDir]path().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
370 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.staterust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]state().(), Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Cleanrust-analyzer cargo dirty-tracker 0.3.0 State#Clean#);
371 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(tracker.pathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]paths().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().());
372
373 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::remove_filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/remove_file().(&file).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
374
375 wait_forrust-analyzer cargo dirty-tracker 0.3.0 tests/wait_for().(&mut tracker, &maplitrust-analyzer cargo maplit 1.0.2 crate/::hashsetrust-analyzer cargo maplit 1.0.2 hashset!![file.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][Clone]clone().()], Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Dirtyrust-analyzer cargo dirty-tracker 0.3.0 State#Dirty#);
376 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.pathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]paths().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&maplitrust-analyzer cargo maplit 1.0.2 crate/::hashsetrust-analyzer cargo maplit 1.0.2 hashset!![file.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][Clone]clone().()]));
377 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
378 tracker.relpathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]relpaths().(),
379 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(maplitrust-analyzer cargo maplit 1.0.2 crate/::hashsetrust-analyzer cargo maplit 1.0.2 hashset!![Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]new().("file")])
380 );
381 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.staterust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]state().(), Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Dirtyrust-analyzer cargo dirty-tracker 0.3.0 State#Dirty#);
382 }
383
384 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
385 fn test_renamerust-analyzer cargo dirty-tracker 0.3.0 tests/test_rename().() {
386 let dir = tempdirrust-analyzer cargo tempfile 3.27.0 dir/tempdir().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
387
388 let file = dir.pathrust-analyzer cargo tempfile 3.27.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("file");
389 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/write().(&file, b"hello").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
390
391 let mut tracker = DirtyTrackerrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#::newrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]new().(dir.pathrust-analyzer cargo tempfile 3.27.0 dir/impl#[TempDir]path().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
392 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.staterust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]state().(), Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Cleanrust-analyzer cargo dirty-tracker 0.3.0 State#Clean#);
393 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(tracker.pathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]paths().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().());
394
395 let new_file = dir.pathrust-analyzer cargo tempfile 3.27.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("new_file");
396 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::renamerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/rename().(&file, &new_file).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
397
398 wait_forrust-analyzer cargo dirty-tracker 0.3.0 tests/wait_for().(
399 &mut tracker,
400 &maplitrust-analyzer cargo maplit 1.0.2 crate/::hashsetrust-analyzer cargo maplit 1.0.2 hashset!![new_file.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][Clone]clone().(), file.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][Clone]clone().()],
401 Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Dirtyrust-analyzer cargo dirty-tracker 0.3.0 State#Dirty#,
402 );
403
404 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
405 tracker.pathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]paths().(),
406 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&maplitrust-analyzer cargo maplit 1.0.2 crate/::hashsetrust-analyzer cargo maplit 1.0.2 hashset!![file.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][Clone]clone().(), new_file.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][Clone]clone().()])
407 );
408 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.staterust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]state().(), Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Dirtyrust-analyzer cargo dirty-tracker 0.3.0 State#Dirty#);
409 }
410
411 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
412 fn test_mark_cleanrust-analyzer cargo dirty-tracker 0.3.0 tests/test_mark_clean().() {
413 let dir = tempdirrust-analyzer cargo tempfile 3.27.0 dir/tempdir().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
414
415 let file = dir.pathrust-analyzer cargo tempfile 3.27.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("file");
416 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/write().(&file, b"hello").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
417
418 let mut tracker = DirtyTrackerrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#::newrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]new().(dir.pathrust-analyzer cargo tempfile 3.27.0 dir/impl#[TempDir]path().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
419 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.staterust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]state().(), Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Cleanrust-analyzer cargo dirty-tracker 0.3.0 State#Clean#);
420 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(tracker.pathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]paths().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().());
421
422 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/write().(&file, b"world").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
423
424 wait_forrust-analyzer cargo dirty-tracker 0.3.0 tests/wait_for().(&mut tracker, &maplitrust-analyzer cargo maplit 1.0.2 crate/::hashsetrust-analyzer cargo maplit 1.0.2 hashset!![file.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][Clone]clone().()], Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Dirtyrust-analyzer cargo dirty-tracker 0.3.0 State#Dirty#);
425 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.pathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]paths().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&maplitrust-analyzer cargo maplit 1.0.2 crate/::hashsetrust-analyzer cargo maplit 1.0.2 hashset!![file.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][Clone]clone().()]));
426 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.staterust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]state().(), Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Dirtyrust-analyzer cargo dirty-tracker 0.3.0 State#Dirty#);
427
428 tracker.mark_cleanrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]mark_clean().();
429 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.staterust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]state().(), Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Cleanrust-analyzer cargo dirty-tracker 0.3.0 State#Clean#);
430 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(tracker.pathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]paths().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().());
431 }
432
433 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
434 fn test_add_and_removerust-analyzer cargo dirty-tracker 0.3.0 tests/test_add_and_remove().() {
435 let dir = tempdirrust-analyzer cargo tempfile 3.27.0 dir/tempdir().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
436
437 let file = dir.pathrust-analyzer cargo tempfile 3.27.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("file");
438 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/write().(file, b"hello").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
439
440 let mut tracker = DirtyTrackerrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#::newrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]new().(dir.pathrust-analyzer cargo tempfile 3.27.0 dir/impl#[TempDir]path().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
441 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.staterust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]state().(), Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Cleanrust-analyzer cargo dirty-tracker 0.3.0 State#Clean#);
442 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(tracker.pathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]paths().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().());
443
444 let file2 = dir.pathrust-analyzer cargo tempfile 3.27.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("file2");
445 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/write().(&file2, b"world").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
446
447 wait_forrust-analyzer cargo dirty-tracker 0.3.0 tests/wait_for().(&mut tracker, &maplitrust-analyzer cargo maplit 1.0.2 crate/::hashsetrust-analyzer cargo maplit 1.0.2 hashset!![file2.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][Clone]clone().()], Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Dirtyrust-analyzer cargo dirty-tracker 0.3.0 State#Dirty#);
448 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.pathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]paths().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&maplitrust-analyzer cargo maplit 1.0.2 crate/::hashsetrust-analyzer cargo maplit 1.0.2 hashset!![file2.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][Clone]clone().()]));
449 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.staterust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]state().(), Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Dirtyrust-analyzer cargo dirty-tracker 0.3.0 State#Dirty#);
450
451 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::remove_filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/remove_file().(&file2).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
452
453 wait_forrust-analyzer cargo dirty-tracker 0.3.0 tests/wait_for().(&mut tracker, &maplitrust-analyzer cargo maplit 1.0.2 crate/::hashsetrust-analyzer cargo maplit 1.0.2 hashset!![], Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Cleanrust-analyzer cargo dirty-tracker 0.3.0 State#Clean#);
454 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.pathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]paths().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&maplitrust-analyzer cargo maplit 1.0.2 crate/::hashsetrust-analyzer cargo maplit 1.0.2 hashset!![]));
455 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.staterust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]state().(), Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Cleanrust-analyzer cargo dirty-tracker 0.3.0 State#Clean#);
456 }
457
458 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
459 fn test_follow_subdirrust-analyzer cargo dirty-tracker 0.3.0 tests/test_follow_subdir().() {
460 let dir = tempdirrust-analyzer cargo tempfile 3.27.0 dir/tempdir().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
461
462 let subdir = dir.pathrust-analyzer cargo tempfile 3.27.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("subdir");
463 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::create_dirrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/create_dir().(&subdir).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
464
465 let file = subdir.joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("file");
466 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/write().(&file, b"hello").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
467
468 let mut tracker = DirtyTrackerrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#::newrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]new().(dir.pathrust-analyzer cargo tempfile 3.27.0 dir/impl#[TempDir]path().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
469 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.staterust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]state().(), Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Cleanrust-analyzer cargo dirty-tracker 0.3.0 State#Clean#);
470 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(tracker.pathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]paths().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().());
471
472 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/write().(&file, b"world").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
473
474 wait_forrust-analyzer cargo dirty-tracker 0.3.0 tests/wait_for().(&mut tracker, &maplitrust-analyzer cargo maplit 1.0.2 crate/::hashsetrust-analyzer cargo maplit 1.0.2 hashset!![file.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][Clone]clone().()], Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Dirtyrust-analyzer cargo dirty-tracker 0.3.0 State#Dirty#);
475 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.pathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]paths().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&maplitrust-analyzer cargo maplit 1.0.2 crate/::hashsetrust-analyzer cargo maplit 1.0.2 hashset!![file.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][Clone]clone().()]));
476 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.staterust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]state().(), Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Dirtyrust-analyzer cargo dirty-tracker 0.3.0 State#Dirty#);
477 }
478
•479 /*#[test]
480 fn test_create_and_follow_subdir() {
481 let dir = tempdir().unwrap();
482
483 let mut tracker = DirtyTracker::new(dir.path()).unwrap();
484 assert_eq!(tracker.state(), State::Clean);
485 assert!(tracker.paths().unwrap().is_empty());
486
487 let subdir = dir.path().join("subdir");
488 std::fs::create_dir(&subdir).unwrap();
489
490 wait_for(
491 &mut tracker,
492 &maplit::hashset![subdir.clone()],
493 State::Dirty,
494 );
495 assert_eq!(tracker.paths(), Some(&maplit::hashset![subdir.clone()]));
496
497 let file = subdir.join("file");
498 std::fs::write(&file, b"hello").unwrap();
499
500 wait_for(
501 &mut tracker,
502 &maplit::hashset![subdir.clone(), file.clone()],
503 State::Dirty,
504 );
505 assert_eq!(
506 tracker.paths(),
507 Some(&maplit::hashset![subdir.clone(), file.clone()])
508 );
509 assert_eq!(tracker.state(), State::Dirty);
•510 }*/
511
512 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
513 fn test_many_addedrust-analyzer cargo dirty-tracker 0.3.0 tests/test_many_added().() {
514 let dir = tempdirrust-analyzer cargo tempfile 3.27.0 dir/tempdir().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
515
516 let mut tracker = DirtyTrackerrust-analyzer cargo dirty-tracker 0.3.0 DirtyTracker#::newrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]new().(dir.pathrust-analyzer cargo tempfile 3.27.0 dir/impl#[TempDir]path().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
517 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.staterust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]state().(), Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Cleanrust-analyzer cargo dirty-tracker 0.3.0 State#Clean#);
518 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(tracker.pathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]paths().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().is_emptyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]is_empty().());
519
520 let mut expected_paths = HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T>`]new().();
521
522 for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#100 {
523 let file = dir.pathrust-analyzer cargo tempfile 3.27.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("file{}", i));
524 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/write().(&file, b"hello").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
525 expected_paths.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]insert().(file.clonerust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][Clone]clone().());
526 }
527
528 wait_forrust-analyzer cargo dirty-tracker 0.3.0 tests/wait_for().(&mut tracker, &expected_paths, Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Dirtyrust-analyzer cargo dirty-tracker 0.3.0 State#Dirty#);
529 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.pathsrust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]paths().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(&expected_paths));
530 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(tracker.staterust-analyzer cargo dirty-tracker 0.3.0 impl#[DirtyTracker]state().(), Staterust-analyzer cargo dirty-tracker 0.3.0 State#::Dirtyrust-analyzer cargo dirty-tracker 0.3.0 State#Dirty#);
531 }
532 }