objc2_core_services/generated/
FSEvents.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "dispatch2")]
8use dispatch2::*;
9#[cfg(feature = "objc2")]
10use objc2::__framework_prelude::*;
11use objc2_core_foundation::*;
12
13use crate::*;
14
15/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/fseventstreamcreateflags?language=objc)
16pub type FSEventStreamCreateFlags = u32;
17
18/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreamcreateflagnone?language=objc)
19pub const kFSEventStreamCreateFlagNone: c_uint = 0x00000000;
20/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreamcreateflagusecftypes?language=objc)
21pub const kFSEventStreamCreateFlagUseCFTypes: c_uint = 0x00000001;
22/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreamcreateflagnodefer?language=objc)
23pub const kFSEventStreamCreateFlagNoDefer: c_uint = 0x00000002;
24/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreamcreateflagwatchroot?language=objc)
25pub const kFSEventStreamCreateFlagWatchRoot: c_uint = 0x00000004;
26/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreamcreateflagignoreself?language=objc)
27pub const kFSEventStreamCreateFlagIgnoreSelf: c_uint = 0x00000008;
28/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreamcreateflagfileevents?language=objc)
29pub const kFSEventStreamCreateFlagFileEvents: c_uint = 0x00000010;
30/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreamcreateflagmarkself?language=objc)
31pub const kFSEventStreamCreateFlagMarkSelf: c_uint = 0x00000020;
32/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreamcreateflaguseextendeddata?language=objc)
33pub const kFSEventStreamCreateFlagUseExtendedData: c_uint = 0x00000040;
34/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreamcreateflagfullhistory?language=objc)
35pub const kFSEventStreamCreateFlagFullHistory: c_uint = 0x00000080;
36/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreamcreatewithdocid?language=objc)
37pub const kFSEventStreamCreateWithDocID: c_uint = 0x00000100;
38/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreamcreatedevicestate?language=objc)
39pub const kFSEventStreamCreateDeviceState: c_uint = 0x00000200;
40
41/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/fseventstreameventflags?language=objc)
42pub type FSEventStreamEventFlags = u32;
43
44/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreameventflagnone?language=objc)
45pub const kFSEventStreamEventFlagNone: c_uint = 0x00000000;
46/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreameventflagmustscansubdirs?language=objc)
47pub const kFSEventStreamEventFlagMustScanSubDirs: c_uint = 0x00000001;
48/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreameventflaguserdropped?language=objc)
49pub const kFSEventStreamEventFlagUserDropped: c_uint = 0x00000002;
50/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreameventflagkerneldropped?language=objc)
51pub const kFSEventStreamEventFlagKernelDropped: c_uint = 0x00000004;
52/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreameventflageventidswrapped?language=objc)
53pub const kFSEventStreamEventFlagEventIdsWrapped: c_uint = 0x00000008;
54/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreameventflaghistorydone?language=objc)
55pub const kFSEventStreamEventFlagHistoryDone: c_uint = 0x00000010;
56/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreameventflagrootchanged?language=objc)
57pub const kFSEventStreamEventFlagRootChanged: c_uint = 0x00000020;
58/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreameventflagmount?language=objc)
59pub const kFSEventStreamEventFlagMount: c_uint = 0x00000040;
60/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreameventflagunmount?language=objc)
61pub const kFSEventStreamEventFlagUnmount: c_uint = 0x00000080;
62/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreameventflagitemcreated?language=objc)
63pub const kFSEventStreamEventFlagItemCreated: c_uint = 0x00000100;
64/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreameventflagitemremoved?language=objc)
65pub const kFSEventStreamEventFlagItemRemoved: c_uint = 0x00000200;
66/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreameventflagiteminodemetamod?language=objc)
67pub const kFSEventStreamEventFlagItemInodeMetaMod: c_uint = 0x00000400;
68/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreameventflagitemrenamed?language=objc)
69pub const kFSEventStreamEventFlagItemRenamed: c_uint = 0x00000800;
70/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreameventflagitemmodified?language=objc)
71pub const kFSEventStreamEventFlagItemModified: c_uint = 0x00001000;
72/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreameventflagitemfinderinfomod?language=objc)
73pub const kFSEventStreamEventFlagItemFinderInfoMod: c_uint = 0x00002000;
74/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreameventflagitemchangeowner?language=objc)
75pub const kFSEventStreamEventFlagItemChangeOwner: c_uint = 0x00004000;
76/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreameventflagitemxattrmod?language=objc)
77pub const kFSEventStreamEventFlagItemXattrMod: c_uint = 0x00008000;
78/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreameventflagitemisfile?language=objc)
79pub const kFSEventStreamEventFlagItemIsFile: c_uint = 0x00010000;
80/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreameventflagitemisdir?language=objc)
81pub const kFSEventStreamEventFlagItemIsDir: c_uint = 0x00020000;
82/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreameventflagitemissymlink?language=objc)
83pub const kFSEventStreamEventFlagItemIsSymlink: c_uint = 0x00040000;
84/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreameventflagownevent?language=objc)
85pub const kFSEventStreamEventFlagOwnEvent: c_uint = 0x00080000;
86/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreameventflagitemishardlink?language=objc)
87pub const kFSEventStreamEventFlagItemIsHardlink: c_uint = 0x00100000;
88/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreameventflagitemislasthardlink?language=objc)
89pub const kFSEventStreamEventFlagItemIsLastHardlink: c_uint = 0x00200000;
90/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/kfseventstreameventflagitemcloned?language=objc)
91pub const kFSEventStreamEventFlagItemCloned: c_uint = 0x00400000;
92
93/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/fseventstreameventid?language=objc)
94pub type FSEventStreamEventId = u64;
95
96/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/__fseventstream?language=objc)
97#[repr(C)]
98#[derive(Debug)]
99pub struct __FSEventStream {
100    inner: [u8; 0],
101    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
102}
103
104#[cfg(feature = "objc2")]
105unsafe impl RefEncode for __FSEventStream {
106    const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("__FSEventStream", &[]));
107}
108
109/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/fseventstreamref?language=objc)
110pub type FSEventStreamRef = *mut __FSEventStream;
111
112/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/fseventstreamcontext?language=objc)
113#[repr(C, packed(2))]
114#[allow(unpredictable_function_pointer_comparisons)]
115#[derive(Clone, Copy, Debug, PartialEq)]
116pub struct FSEventStreamContext {
117    pub version: CFIndex,
118    pub info: *mut c_void,
119    pub retain: CFAllocatorRetainCallBack,
120    pub release: CFAllocatorReleaseCallBack,
121    pub copyDescription: CFAllocatorCopyDescriptionCallBack,
122}
123
124#[cfg(feature = "objc2")]
125unsafe impl Encode for FSEventStreamContext {
126    const ENCODING: Encoding = Encoding::Struct(
127        "FSEventStreamContext",
128        &[
129            <CFIndex>::ENCODING,
130            <*mut c_void>::ENCODING,
131            <CFAllocatorRetainCallBack>::ENCODING,
132            <CFAllocatorReleaseCallBack>::ENCODING,
133            <CFAllocatorCopyDescriptionCallBack>::ENCODING,
134        ],
135    );
136}
137
138#[cfg(feature = "objc2")]
139unsafe impl RefEncode for FSEventStreamContext {
140    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
141}
142
143/// [Apple's documentation](https://developer.apple.com/documentation/coreservices/fseventstreamcallback?language=objc)
144pub type FSEventStreamCallback = Option<
145    unsafe extern "C-unwind" fn(
146        ConstFSEventStreamRef,
147        *mut c_void,
148        usize,
149        NonNull<c_void>,
150        NonNull<FSEventStreamEventFlags>,
151        NonNull<FSEventStreamEventId>,
152    ),
153>;
154
155extern "C-unwind" {
156    /// # Safety
157    ///
158    /// - `callback` must be implemented correctly.
159    /// - `context` must be a valid pointer or null.
160    /// - `paths_to_watch` generic must be of the correct type.
161    pub fn FSEventStreamCreate(
162        allocator: Option<&CFAllocator>,
163        callback: FSEventStreamCallback,
164        context: *mut FSEventStreamContext,
165        paths_to_watch: &CFArray,
166        since_when: FSEventStreamEventId,
167        latency: CFTimeInterval,
168        flags: FSEventStreamCreateFlags,
169    ) -> FSEventStreamRef;
170}
171
172extern "C-unwind" {
173    /// # Safety
174    ///
175    /// - `callback` must be implemented correctly.
176    /// - `context` must be a valid pointer or null.
177    /// - `paths_to_watch_relative_to_device` generic must be of the correct type.
178    #[cfg(feature = "libc")]
179    pub fn FSEventStreamCreateRelativeToDevice(
180        allocator: Option<&CFAllocator>,
181        callback: FSEventStreamCallback,
182        context: *mut FSEventStreamContext,
183        device_to_watch: libc::dev_t,
184        paths_to_watch_relative_to_device: &CFArray,
185        since_when: FSEventStreamEventId,
186        latency: CFTimeInterval,
187        flags: FSEventStreamCreateFlags,
188    ) -> FSEventStreamRef;
189}
190
191extern "C-unwind" {
192    /// # Safety
193    ///
194    /// `stream_ref` must be a valid pointer.
195    pub fn FSEventStreamGetLatestEventId(stream_ref: ConstFSEventStreamRef)
196        -> FSEventStreamEventId;
197}
198
199extern "C-unwind" {
200    /// # Safety
201    ///
202    /// `stream_ref` must be a valid pointer.
203    #[cfg(feature = "libc")]
204    pub fn FSEventStreamGetDeviceBeingWatched(stream_ref: ConstFSEventStreamRef) -> libc::dev_t;
205}
206
207/// # Safety
208///
209/// `stream_ref` must be a valid pointer.
210#[inline]
211pub unsafe extern "C-unwind" fn FSEventStreamCopyPathsBeingWatched(
212    stream_ref: ConstFSEventStreamRef,
213) -> CFRetained<CFArray> {
214    extern "C-unwind" {
215        fn FSEventStreamCopyPathsBeingWatched(
216            stream_ref: ConstFSEventStreamRef,
217        ) -> Option<NonNull<CFArray>>;
218    }
219    let ret = unsafe { FSEventStreamCopyPathsBeingWatched(stream_ref) };
220    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
221    unsafe { CFRetained::from_raw(ret) }
222}
223
224extern "C-unwind" {
225    pub fn FSEventsGetCurrentEventId() -> FSEventStreamEventId;
226}
227
228#[cfg(feature = "libc")]
229#[inline]
230pub unsafe extern "C-unwind" fn FSEventsCopyUUIDForDevice(
231    dev: libc::dev_t,
232) -> Option<CFRetained<CFUUID>> {
233    extern "C-unwind" {
234        fn FSEventsCopyUUIDForDevice(dev: libc::dev_t) -> Option<NonNull<CFUUID>>;
235    }
236    let ret = unsafe { FSEventsCopyUUIDForDevice(dev) };
237    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
238}
239
240extern "C-unwind" {
241    #[cfg(feature = "libc")]
242    pub fn FSEventsGetLastEventIdForDeviceBeforeTime(
243        dev: libc::dev_t,
244        time: CFAbsoluteTime,
245    ) -> FSEventStreamEventId;
246}
247
248#[cfg(feature = "libc")]
249#[inline]
250pub unsafe extern "C-unwind" fn FSEventsPurgeEventsForDeviceUpToEventId(
251    dev: libc::dev_t,
252    event_id: FSEventStreamEventId,
253) -> bool {
254    extern "C-unwind" {
255        fn FSEventsPurgeEventsForDeviceUpToEventId(
256            dev: libc::dev_t,
257            event_id: FSEventStreamEventId,
258        ) -> Boolean;
259    }
260    let ret = unsafe { FSEventsPurgeEventsForDeviceUpToEventId(dev, event_id) };
261    ret != 0
262}
263
264extern "C-unwind" {
265    /// # Safety
266    ///
267    /// `stream_ref` must be a valid pointer.
268    pub fn FSEventStreamRetain(stream_ref: FSEventStreamRef);
269}
270
271extern "C-unwind" {
272    /// # Safety
273    ///
274    /// `stream_ref` must be a valid pointer.
275    pub fn FSEventStreamRelease(stream_ref: FSEventStreamRef);
276}
277
278extern "C-unwind" {
279    /// # Safety
280    ///
281    /// - `stream_ref` must be a valid pointer.
282    /// - `run_loop` possibly has additional threading requirements.
283    #[deprecated = "Use FSEventStreamSetDispatchQueue instead."]
284    pub fn FSEventStreamScheduleWithRunLoop(
285        stream_ref: FSEventStreamRef,
286        run_loop: &CFRunLoop,
287        run_loop_mode: &CFString,
288    );
289}
290
291extern "C-unwind" {
292    /// # Safety
293    ///
294    /// - `stream_ref` must be a valid pointer.
295    /// - `run_loop` possibly has additional threading requirements.
296    #[deprecated = "Use FSEventStreamSetDispatchQueue instead."]
297    pub fn FSEventStreamUnscheduleFromRunLoop(
298        stream_ref: FSEventStreamRef,
299        run_loop: &CFRunLoop,
300        run_loop_mode: &CFString,
301    );
302}
303
304extern "C-unwind" {
305    /// # Safety
306    ///
307    /// - `stream_ref` must be a valid pointer.
308    /// - `q` possibly has additional threading requirements.
309    #[cfg(feature = "dispatch2")]
310    pub fn FSEventStreamSetDispatchQueue(stream_ref: FSEventStreamRef, q: Option<&DispatchQueue>);
311}
312
313extern "C-unwind" {
314    /// # Safety
315    ///
316    /// `stream_ref` must be a valid pointer.
317    pub fn FSEventStreamInvalidate(stream_ref: FSEventStreamRef);
318}
319
320/// # Safety
321///
322/// `stream_ref` must be a valid pointer.
323#[inline]
324pub unsafe extern "C-unwind" fn FSEventStreamStart(stream_ref: FSEventStreamRef) -> bool {
325    extern "C-unwind" {
326        fn FSEventStreamStart(stream_ref: FSEventStreamRef) -> Boolean;
327    }
328    let ret = unsafe { FSEventStreamStart(stream_ref) };
329    ret != 0
330}
331
332extern "C-unwind" {
333    /// # Safety
334    ///
335    /// `stream_ref` must be a valid pointer.
336    pub fn FSEventStreamFlushAsync(stream_ref: FSEventStreamRef) -> FSEventStreamEventId;
337}
338
339extern "C-unwind" {
340    /// # Safety
341    ///
342    /// `stream_ref` must be a valid pointer.
343    pub fn FSEventStreamFlushSync(stream_ref: FSEventStreamRef);
344}
345
346extern "C-unwind" {
347    /// # Safety
348    ///
349    /// `stream_ref` must be a valid pointer.
350    pub fn FSEventStreamStop(stream_ref: FSEventStreamRef);
351}
352
353extern "C-unwind" {
354    /// # Safety
355    ///
356    /// `stream_ref` must be a valid pointer.
357    pub fn FSEventStreamShow(stream_ref: ConstFSEventStreamRef);
358}
359
360/// # Safety
361///
362/// `stream_ref` must be a valid pointer.
363#[inline]
364pub unsafe extern "C-unwind" fn FSEventStreamCopyDescription(
365    stream_ref: ConstFSEventStreamRef,
366) -> CFRetained<CFString> {
367    extern "C-unwind" {
368        fn FSEventStreamCopyDescription(
369            stream_ref: ConstFSEventStreamRef,
370        ) -> Option<NonNull<CFString>>;
371    }
372    let ret = unsafe { FSEventStreamCopyDescription(stream_ref) };
373    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
374    unsafe { CFRetained::from_raw(ret) }
375}
376
377/// # Safety
378///
379/// - `stream_ref` must be a valid pointer.
380/// - `paths_to_exclude` generic must be of the correct type.
381#[inline]
382pub unsafe extern "C-unwind" fn FSEventStreamSetExclusionPaths(
383    stream_ref: FSEventStreamRef,
384    paths_to_exclude: &CFArray,
385) -> bool {
386    extern "C-unwind" {
387        fn FSEventStreamSetExclusionPaths(
388            stream_ref: FSEventStreamRef,
389            paths_to_exclude: &CFArray,
390        ) -> Boolean;
391    }
392    let ret = unsafe { FSEventStreamSetExclusionPaths(stream_ref, paths_to_exclude) };
393    ret != 0
394}