1- use debounced:: { Debounced , debounced} ;
21use inotify:: { EventStream , Inotify , WatchDescriptor , WatchMask , Watches } ;
32use tokio:: fs:: { File , read_dir} ;
43use tokio:: time:: { Interval , interval} ;
@@ -20,27 +19,24 @@ pub(super) struct Monitor<'a> {
2019 devices : HashMap < PathBuf , WatchDescriptor > ,
2120 interval : Interval ,
2221 watches : Watches ,
23- updates : Debounced < EventStream < [ u8 ; 1024 ] > > ,
22+ stream : EventStream < [ u8 ; 1024 ] > ,
2423}
2524
2625impl < ' a > Monitor < ' a > {
2726 pub ( super ) async fn new ( config : & ' a Config , duration : Duration ) -> Result < Self > {
2827 let notify = Inotify :: init ( ) . error ( "Failed to start inotify" ) ?;
2928 let watches = notify. watches ( ) ;
3029
31- let updates = debounced (
32- notify
33- . into_event_stream ( [ 0 ; 1024 ] )
34- . error ( "Failed to create event stream" ) ?,
35- Duration :: from_millis ( 100 ) ,
36- ) ;
30+ let stream = notify
31+ . into_event_stream ( [ 0 ; 1024 ] )
32+ . error ( "Failed to create event stream" ) ?;
3733
3834 let mut s = Self {
3935 config,
4036 devices : HashMap :: new ( ) ,
4137 interval : interval ( duration) ,
4238 watches,
43- updates ,
39+ stream ,
4440 } ;
4541 s. update_devices ( ) . await ?;
4642
@@ -149,7 +145,7 @@ impl PrivacyMonitor for Monitor<'_> {
149145 break ;
150146 }
151147 } ,
152- _ = self . updates . next ( ) => break ,
148+ _ = self . stream . next_debounced ( ) => break
153149 }
154150 }
155151 Ok ( ( ) )
0 commit comments