objc2_foundation/generated/
NSDistributedNotificationCenter.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9#[cfg(feature = "NSString")]
12pub type NSDistributedNotificationCenterType = NSString;
13
14extern "C" {
15 #[cfg(feature = "NSString")]
17 pub static NSLocalNotificationCenterType: &'static NSDistributedNotificationCenterType;
18}
19
20#[repr(transparent)]
23#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
24pub struct NSNotificationSuspensionBehavior(pub NSUInteger);
25impl NSNotificationSuspensionBehavior {
26 #[doc(alias = "NSNotificationSuspensionBehaviorDrop")]
27 pub const Drop: Self = Self(1);
28 #[doc(alias = "NSNotificationSuspensionBehaviorCoalesce")]
29 pub const Coalesce: Self = Self(2);
30 #[doc(alias = "NSNotificationSuspensionBehaviorHold")]
31 pub const Hold: Self = Self(3);
32 #[doc(alias = "NSNotificationSuspensionBehaviorDeliverImmediately")]
33 pub const DeliverImmediately: Self = Self(4);
34}
35
36unsafe impl Encode for NSNotificationSuspensionBehavior {
37 const ENCODING: Encoding = NSUInteger::ENCODING;
38}
39
40unsafe impl RefEncode for NSNotificationSuspensionBehavior {
41 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
42}
43
44#[repr(transparent)]
47#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
48pub struct NSDistributedNotificationOptions(pub NSUInteger);
49bitflags::bitflags! {
50 impl NSDistributedNotificationOptions: NSUInteger {
51 #[doc(alias = "NSDistributedNotificationDeliverImmediately")]
52 const DeliverImmediately = 1<<0;
53 #[doc(alias = "NSDistributedNotificationPostToAllSessions")]
54 const PostToAllSessions = 1<<1;
55 }
56}
57
58unsafe impl Encode for NSDistributedNotificationOptions {
59 const ENCODING: Encoding = NSUInteger::ENCODING;
60}
61
62unsafe impl RefEncode for NSDistributedNotificationOptions {
63 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
64}
65
66pub static NSNotificationDeliverImmediately: NSDistributedNotificationOptions =
68 NSDistributedNotificationOptions(NSDistributedNotificationOptions::DeliverImmediately.0);
69
70pub static NSNotificationPostToAllSessions: NSDistributedNotificationOptions =
72 NSDistributedNotificationOptions(NSDistributedNotificationOptions::PostToAllSessions.0);
73
74extern_class!(
75 #[unsafe(super(NSNotificationCenter, NSObject))]
77 #[derive(Debug, PartialEq, Eq, Hash)]
78 #[cfg(feature = "NSNotification")]
79 pub struct NSDistributedNotificationCenter;
80);
81
82#[cfg(feature = "NSNotification")]
83extern_conformance!(
84 unsafe impl NSObjectProtocol for NSDistributedNotificationCenter {}
85);
86
87#[cfg(feature = "NSNotification")]
88impl NSDistributedNotificationCenter {
89 extern_methods!(
90 #[cfg(feature = "NSString")]
91 #[unsafe(method(notificationCenterForType:))]
92 #[unsafe(method_family = none)]
93 pub fn notificationCenterForType(
94 notification_center_type: &NSDistributedNotificationCenterType,
95 ) -> Retained<NSDistributedNotificationCenter>;
96
97 #[unsafe(method(defaultCenter))]
98 #[unsafe(method_family = none)]
99 pub fn defaultCenter() -> Retained<NSDistributedNotificationCenter>;
100
101 #[cfg(feature = "NSString")]
102 #[unsafe(method(addObserver:selector:name:object:suspensionBehavior:))]
107 #[unsafe(method_family = none)]
108 pub unsafe fn addObserver_selector_name_object_suspensionBehavior(
109 &self,
110 observer: &AnyObject,
111 selector: Sel,
112 name: Option<&NSNotificationName>,
113 object: Option<&NSString>,
114 suspension_behavior: NSNotificationSuspensionBehavior,
115 );
116
117 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
118 #[unsafe(method(postNotificationName:object:userInfo:deliverImmediately:))]
122 #[unsafe(method_family = none)]
123 pub unsafe fn postNotificationName_object_userInfo_deliverImmediately(
124 &self,
125 name: &NSNotificationName,
126 object: Option<&NSString>,
127 user_info: Option<&NSDictionary>,
128 deliver_immediately: bool,
129 );
130
131 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
132 #[unsafe(method(postNotificationName:object:userInfo:options:))]
136 #[unsafe(method_family = none)]
137 pub unsafe fn postNotificationName_object_userInfo_options(
138 &self,
139 name: &NSNotificationName,
140 object: Option<&NSString>,
141 user_info: Option<&NSDictionary>,
142 options: NSDistributedNotificationOptions,
143 );
144
145 #[unsafe(method(suspended))]
146 #[unsafe(method_family = none)]
147 pub fn suspended(&self) -> bool;
148
149 #[unsafe(method(setSuspended:))]
151 #[unsafe(method_family = none)]
152 pub fn setSuspended(&self, suspended: bool);
153
154 #[cfg(feature = "NSString")]
155 #[unsafe(method(addObserver:selector:name:object:))]
160 #[unsafe(method_family = none)]
161 pub unsafe fn addObserver_selector_name_object(
162 &self,
163 observer: &AnyObject,
164 a_selector: Sel,
165 a_name: Option<&NSNotificationName>,
166 an_object: Option<&NSString>,
167 );
168
169 #[cfg(feature = "NSString")]
170 #[unsafe(method(postNotificationName:object:))]
171 #[unsafe(method_family = none)]
172 pub unsafe fn postNotificationName_object(
173 &self,
174 a_name: &NSNotificationName,
175 an_object: Option<&NSString>,
176 );
177
178 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
179 #[unsafe(method(postNotificationName:object:userInfo:))]
183 #[unsafe(method_family = none)]
184 pub unsafe fn postNotificationName_object_userInfo(
185 &self,
186 a_name: &NSNotificationName,
187 an_object: Option<&NSString>,
188 a_user_info: Option<&NSDictionary>,
189 );
190
191 #[cfg(feature = "NSString")]
192 #[unsafe(method(removeObserver:name:object:))]
196 #[unsafe(method_family = none)]
197 pub unsafe fn removeObserver_name_object(
198 &self,
199 observer: &AnyObject,
200 a_name: Option<&NSNotificationName>,
201 an_object: Option<&NSString>,
202 );
203 );
204}
205
206#[cfg(feature = "NSNotification")]
208impl NSDistributedNotificationCenter {
209 extern_methods!(
210 #[unsafe(method(init))]
211 #[unsafe(method_family = init)]
212 pub fn init(this: Allocated<Self>) -> Retained<Self>;
213
214 #[unsafe(method(new))]
215 #[unsafe(method_family = new)]
216 pub fn new() -> Retained<Self>;
217 );
218}
219
220#[cfg(feature = "NSNotification")]
221impl DefaultRetained for NSDistributedNotificationCenter {
222 #[inline]
223 fn default_retained() -> Retained<Self> {
224 Self::new()
225 }
226}