5 releases

Uses new Rust 2021

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

#21 in macOS and iOS APIs

Download history 37/week @ 2021-12-02 66/week @ 2021-12-09 2/week @ 2021-12-16 5/week @ 2021-12-30 24/week @ 2022-01-06 14/week @ 2022-01-13 20/week @ 2022-01-20

63 downloads per month

MIT license

47KB
923 lines

fsevent-stream

GitHub Workflow Status crates.io Documentation

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.

FOSSA Status

Dependencies

~3MB
~49K SLoC