5 releases
0.2.3 | Jan 9, 2022 |
---|---|
0.2.2 | Dec 12, 2021 |
0.2.1 | Dec 9, 2021 |
0.2.0 | Dec 4, 2021 |
0.1.0 | Dec 4, 2021 |
#1288 in Filesystem
24 downloads per month
49KB
923 lines
fsevent-stream
Stream-based FSEvents
API bindings.
Features
- Support directory-granular and file-granular events.
- Retrieve related file inode with
kFSEventStreamCreateFlagUseExtendedData
.
Example
use std::path::Path;
use std::time::Duration;
use fsevent_stream::ffi::{
kFSEventStreamCreateFlagFileEvents, kFSEventStreamCreateFlagNoDefer,
kFSEventStreamCreateFlagUseCFTypes, kFSEventStreamCreateFlagUseExtendedData,
kFSEventStreamEventIdSinceNow,
};
use fsevent_stream::stream::create_event_stream;
use futures_util::StreamExt;
let (stream, handler) = create_event_stream(
[Path::new(".")],
kFSEventStreamEventIdSinceNow,
Duration::ZERO,
kFSEventStreamCreateFlagNoDefer
| kFSEventStreamCreateFlagFileEvents
| kFSEventStreamCreateFlagUseExtendedData
| kFSEventStreamCreateFlagUseCFTypes,
)
.expect("stream to be created");
let mut stream = stream.into_flatten();
while let Some(event) = stream.next().await {
println!(
"[{}] path: {:?}({}), flags: {} ({:x})",
event.id,
event.path,
event.inode.unwrap_or(-1),
event.flags,
event.raw_flags
);
}
Runtime Support
Both tokio
and async-std
are supported
via feature flags.
tokio
support is enabled by default. To enable async-std
support, disable default features and enable async-std
feature.
Acknowledgement
Some code in this project is adapted from the following projects:
License
This project is licensed under MIT License.
Dependencies
~1–4MB
~75K SLoC