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

#1524 in Filesystem

Download history 2/week @ 2024-09-23 5/week @ 2024-11-11 50/week @ 2024-11-18 58/week @ 2024-11-25 66/week @ 2024-12-02 40/week @ 2024-12-09

215 downloads per month

MIT license

49KB
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

~1–8.5MB
~77K SLoC