This PR upgrades our [`bitflags`](https://crates.io/crates/bitflags) dependency to v2.4.2. This also fixes an error that was seen when running `clippy`: ``` error: &-masking with zero --> crates/fsevent/src/fsevent.rs:19:1 | 19 | / bitflags! { 20 | | #[repr(C)] 21 | | pub struct StreamFlags: u32 { 22 | | const NONE = 0x00000000; ... | 46 | | } 47 | | } | |_^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#bad_bit_mask = note: `#[deny(clippy::bad_bit_mask)]` on by default = note: this error originates in the macro `__impl_bitflags` which comes from the expansion of the macro `bitflags` (in Nightly builds, run with -Z macro-backtrace for more info) ``` Fixes #8681. Release Notes: - N/A
124 lines
4.0 KiB
Rust
124 lines
4.0 KiB
Rust
#[cfg(target_os = "macos")]
|
|
pub use mac_impl::*;
|
|
|
|
use bitflags::bitflags;
|
|
use std::path::PathBuf;
|
|
|
|
#[cfg(target_os = "macos")]
|
|
mod mac_impl;
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub struct Event {
|
|
pub event_id: u64,
|
|
pub flags: StreamFlags,
|
|
pub path: PathBuf,
|
|
}
|
|
|
|
// Synchronize with
|
|
// /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/FSEvents.framework/Versions/A/Headers/FSEvents.h
|
|
bitflags! {
|
|
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
|
#[repr(C)]
|
|
pub struct StreamFlags: u32 {
|
|
const NONE = 0x00000000;
|
|
const MUST_SCAN_SUBDIRS = 0x00000001;
|
|
const USER_DROPPED = 0x00000002;
|
|
const KERNEL_DROPPED = 0x00000004;
|
|
const IDS_WRAPPED = 0x00000008;
|
|
const HISTORY_DONE = 0x00000010;
|
|
const ROOT_CHANGED = 0x00000020;
|
|
const MOUNT = 0x00000040;
|
|
const UNMOUNT = 0x00000080;
|
|
const ITEM_CREATED = 0x00000100;
|
|
const ITEM_REMOVED = 0x00000200;
|
|
const INODE_META_MOD = 0x00000400;
|
|
const ITEM_RENAMED = 0x00000800;
|
|
const ITEM_MODIFIED = 0x00001000;
|
|
const FINDER_INFO_MOD = 0x00002000;
|
|
const ITEM_CHANGE_OWNER = 0x00004000;
|
|
const ITEM_XATTR_MOD = 0x00008000;
|
|
const IS_FILE = 0x00010000;
|
|
const IS_DIR = 0x00020000;
|
|
const IS_SYMLINK = 0x00040000;
|
|
const OWN_EVENT = 0x00080000;
|
|
const IS_HARDLINK = 0x00100000;
|
|
const IS_LAST_HARDLINK = 0x00200000;
|
|
const ITEM_CLONED = 0x400000;
|
|
}
|
|
}
|
|
|
|
impl std::fmt::Display for StreamFlags {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
if self.contains(StreamFlags::MUST_SCAN_SUBDIRS) {
|
|
let _d = write!(f, "MUST_SCAN_SUBDIRS ");
|
|
}
|
|
if self.contains(StreamFlags::USER_DROPPED) {
|
|
let _d = write!(f, "USER_DROPPED ");
|
|
}
|
|
if self.contains(StreamFlags::KERNEL_DROPPED) {
|
|
let _d = write!(f, "KERNEL_DROPPED ");
|
|
}
|
|
if self.contains(StreamFlags::IDS_WRAPPED) {
|
|
let _d = write!(f, "IDS_WRAPPED ");
|
|
}
|
|
if self.contains(StreamFlags::HISTORY_DONE) {
|
|
let _d = write!(f, "HISTORY_DONE ");
|
|
}
|
|
if self.contains(StreamFlags::ROOT_CHANGED) {
|
|
let _d = write!(f, "ROOT_CHANGED ");
|
|
}
|
|
if self.contains(StreamFlags::MOUNT) {
|
|
let _d = write!(f, "MOUNT ");
|
|
}
|
|
if self.contains(StreamFlags::UNMOUNT) {
|
|
let _d = write!(f, "UNMOUNT ");
|
|
}
|
|
if self.contains(StreamFlags::ITEM_CREATED) {
|
|
let _d = write!(f, "ITEM_CREATED ");
|
|
}
|
|
if self.contains(StreamFlags::ITEM_REMOVED) {
|
|
let _d = write!(f, "ITEM_REMOVED ");
|
|
}
|
|
if self.contains(StreamFlags::INODE_META_MOD) {
|
|
let _d = write!(f, "INODE_META_MOD ");
|
|
}
|
|
if self.contains(StreamFlags::ITEM_RENAMED) {
|
|
let _d = write!(f, "ITEM_RENAMED ");
|
|
}
|
|
if self.contains(StreamFlags::ITEM_MODIFIED) {
|
|
let _d = write!(f, "ITEM_MODIFIED ");
|
|
}
|
|
if self.contains(StreamFlags::FINDER_INFO_MOD) {
|
|
let _d = write!(f, "FINDER_INFO_MOD ");
|
|
}
|
|
if self.contains(StreamFlags::ITEM_CHANGE_OWNER) {
|
|
let _d = write!(f, "ITEM_CHANGE_OWNER ");
|
|
}
|
|
if self.contains(StreamFlags::ITEM_XATTR_MOD) {
|
|
let _d = write!(f, "ITEM_XATTR_MOD ");
|
|
}
|
|
if self.contains(StreamFlags::IS_FILE) {
|
|
let _d = write!(f, "IS_FILE ");
|
|
}
|
|
if self.contains(StreamFlags::IS_DIR) {
|
|
let _d = write!(f, "IS_DIR ");
|
|
}
|
|
if self.contains(StreamFlags::IS_SYMLINK) {
|
|
let _d = write!(f, "IS_SYMLINK ");
|
|
}
|
|
if self.contains(StreamFlags::OWN_EVENT) {
|
|
let _d = write!(f, "OWN_EVENT ");
|
|
}
|
|
if self.contains(StreamFlags::IS_LAST_HARDLINK) {
|
|
let _d = write!(f, "IS_LAST_HARDLINK ");
|
|
}
|
|
if self.contains(StreamFlags::IS_HARDLINK) {
|
|
let _d = write!(f, "IS_HARDLINK ");
|
|
}
|
|
if self.contains(StreamFlags::ITEM_CLONED) {
|
|
let _d = write!(f, "ITEM_CLONED ");
|
|
}
|
|
write!(f, "")
|
|
}
|
|
}
|