dispatch2/
source.rs

1#![allow(non_camel_case_types)] // TODO
2#![allow(missing_docs)] // TODO
3use core::ffi::c_ulong;
4
5dispatch_object!(
6    /// Dispatch source.
7    #[doc(alias = "dispatch_source_t")]
8    #[doc(alias = "dispatch_source_s")]
9    pub struct DispatchSource;
10);
11
12dispatch_object_not_data!(unsafe DispatchSource);
13
14#[repr(C)]
15#[derive(Debug)]
16pub struct dispatch_source_type_s {
17    /// opaque value
18    _inner: [u8; 0],
19    _p: crate::OpaqueData,
20}
21
22#[cfg(feature = "objc2")]
23// SAFETY: Dispatch types are internally objects.
24unsafe impl objc2::encode::RefEncode for dispatch_source_type_s {
25    const ENCODING_REF: objc2::encode::Encoding = objc2::encode::Encoding::Object;
26}
27
28#[allow(missing_docs)]
29pub type dispatch_source_type_t = *mut dispatch_source_type_s;
30
31enum_with_val! {
32    /// Mach send-right flags.
33    #[derive(PartialEq, Eq, Clone, Copy)]
34    pub struct dispatch_source_mach_send_flags_t(pub c_ulong) {
35        DISPATCH_MACH_SEND_DEAD = 0x1
36    }
37}
38
39enum_with_val! {
40    /// Mach receive-right flags.
41    #[derive(PartialEq, Eq, Clone, Copy)]
42    pub struct dispatch_source_mach_recv_flags_t(pub c_ulong) {
43        // no definition
44    }
45}
46
47enum_with_val! {
48    // Memory pressure events.
49    #[derive(PartialEq, Eq, Clone, Copy)]
50    pub struct dispatch_source_memorypressure_flags_t(pub c_ulong) {
51        DISPATCH_MEMORYPRESSURE_NORMAL = 0x1,
52        DISPATCH_MEMORYPRESSURE_WARN = 0x2,
53        DISPATCH_MEMORYPRESSURE_CRITICAL = 0x4,
54    }
55}
56
57enum_with_val! {
58    /// Events related to a process.
59    #[derive(PartialEq, Eq, Clone, Copy)]
60    pub struct dispatch_source_proc_flags_t(pub c_ulong) {
61        DISPATCH_PROC_EXIT = 0x80000000,
62        DISPATCH_PROC_FORK = 0x40000000,
63        DISPATCH_PROC_EXEC = 0x20000000,
64        DISPATCH_PROC_SIGNAL = 0x08000000,
65    }
66}
67
68enum_with_val! {
69    /// Events involving a change to a file system object.
70    #[derive(PartialEq, Eq, Clone, Copy)]
71    pub struct dispatch_source_vnode_flags_t(pub c_ulong) {
72        DISPATCH_VNODE_DELETE = 0x1,
73        DISPATCH_VNODE_WRITE = 0x2,
74        DISPATCH_VNODE_EXTEND = 0x4,
75        DISPATCH_VNODE_ATTRIB = 0x8,
76        DISPATCH_VNODE_LINK = 0x10,
77        DISPATCH_VNODE_RENAME = 0x20,
78        DISPATCH_VNODE_REVOKE = 0x40,
79        DISPATCH_VNODE_FUNLOCK = 0x100,
80    }
81}
82
83enum_with_val! {
84    /// Flags to use when configuring a timer dispatch source.
85    #[derive(PartialEq, Eq, Clone, Copy)]
86    pub struct dispatch_source_timer_flags_t(pub c_ulong) {
87        DISPATCH_TIMER_STRICT = 0x1,
88    }
89}