fsevent-stream

Crates.iofsevent-stream
lib.rsfsevent-stream
version0.2.3
sourcesrc
created_at2021-12-04 16:49:14.595878
updated_at2022-01-09 15:41:18.534982
descriptionStream-based FSEvent API bindings.
homepage
repositoryhttps://github.com/PhotonQuantum/fsevent-stream
max_upload_size
id492287
size70,131
LightQuantum (PhotonQuantum)

documentation

README

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

Commit count: 94

cargo fmt