https://github.com/photonquantum/fsevent-stream
Stream-based FSEvents API bindings.
https://github.com/photonquantum/fsevent-stream
filesystem fsevent macos notify rust watcher
Last synced: over 1 year ago
JSON representation
Stream-based FSEvents API bindings.
- Host: GitHub
- URL: https://github.com/photonquantum/fsevent-stream
- Owner: PhotonQuantum
- License: mit
- Created: 2021-12-01T15:55:13.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-10-18T08:57:54.000Z (over 1 year ago)
- Last Synced: 2025-03-14T20:53:31.797Z (over 1 year ago)
- Topics: filesystem, fsevent, macos, notify, rust, watcher
- Language: Rust
- Homepage:
- Size: 175 KB
- Stars: 7
- Watchers: 1
- Forks: 2
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fsevent-stream
[](https://github.com/PhotonQuantum/fsevent-stream/actions/workflows/test.yml)
[](https://crates.io/crates/fsevent-stream)
[](https://docs.rs/fsevent-stream)
Stream-based [`FSEvents`](https://developer.apple.com/documentation/coreservices/file_system_events) API bindings.
## Features
- Support directory-granular and file-granular events.
- Retrieve related file inode with `kFSEventStreamCreateFlagUseExtendedData`.
## Example
```rust
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`](https://github.com/tokio-rs/tokio) and [`async-std`](https://github.com/async-rs/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:
- [fsevent-sys](https://github.com/octplane/fsevent-rust)
- [notify](https://github.com/notify-rs/notify)
## License
This project is licensed under [MIT License](LICENSE).
[](https://app.fossa.com/projects/git%2Bgithub.com%2FPhotonQuantum%2Ffsevent-better?ref=badge_large)