objc2_foundation/generated/
NSKeyValueObserving.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9#[repr(transparent)]
12#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
13pub struct NSKeyValueObservingOptions(pub NSUInteger);
14bitflags::bitflags! {
15 impl NSKeyValueObservingOptions: NSUInteger {
16 #[doc(alias = "NSKeyValueObservingOptionNew")]
17 const New = 0x01;
18 #[doc(alias = "NSKeyValueObservingOptionOld")]
19 const Old = 0x02;
20 #[doc(alias = "NSKeyValueObservingOptionInitial")]
21 const Initial = 0x04;
22 #[doc(alias = "NSKeyValueObservingOptionPrior")]
23 const Prior = 0x08;
24 }
25}
26
27unsafe impl Encode for NSKeyValueObservingOptions {
28 const ENCODING: Encoding = NSUInteger::ENCODING;
29}
30
31unsafe impl RefEncode for NSKeyValueObservingOptions {
32 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
33}
34
35#[repr(transparent)]
38#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
39pub struct NSKeyValueChange(pub NSUInteger);
40impl NSKeyValueChange {
41 #[doc(alias = "NSKeyValueChangeSetting")]
42 pub const Setting: Self = Self(1);
43 #[doc(alias = "NSKeyValueChangeInsertion")]
44 pub const Insertion: Self = Self(2);
45 #[doc(alias = "NSKeyValueChangeRemoval")]
46 pub const Removal: Self = Self(3);
47 #[doc(alias = "NSKeyValueChangeReplacement")]
48 pub const Replacement: Self = Self(4);
49}
50
51unsafe impl Encode for NSKeyValueChange {
52 const ENCODING: Encoding = NSUInteger::ENCODING;
53}
54
55unsafe impl RefEncode for NSKeyValueChange {
56 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
57}
58
59#[repr(transparent)]
62#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
63pub struct NSKeyValueSetMutationKind(pub NSUInteger);
64impl NSKeyValueSetMutationKind {
65 #[doc(alias = "NSKeyValueUnionSetMutation")]
66 pub const UnionSetMutation: Self = Self(1);
67 #[doc(alias = "NSKeyValueMinusSetMutation")]
68 pub const MinusSetMutation: Self = Self(2);
69 #[doc(alias = "NSKeyValueIntersectSetMutation")]
70 pub const IntersectSetMutation: Self = Self(3);
71 #[doc(alias = "NSKeyValueSetSetMutation")]
72 pub const SetSetMutation: Self = Self(4);
73}
74
75unsafe impl Encode for NSKeyValueSetMutationKind {
76 const ENCODING: Encoding = NSUInteger::ENCODING;
77}
78
79unsafe impl RefEncode for NSKeyValueSetMutationKind {
80 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
81}
82
83#[cfg(feature = "NSString")]
86pub type NSKeyValueChangeKey = NSString;
87
88extern "C" {
89 #[cfg(feature = "NSString")]
91 pub static NSKeyValueChangeKindKey: &'static NSKeyValueChangeKey;
92}
93
94extern "C" {
95 #[cfg(feature = "NSString")]
97 pub static NSKeyValueChangeNewKey: &'static NSKeyValueChangeKey;
98}
99
100extern "C" {
101 #[cfg(feature = "NSString")]
103 pub static NSKeyValueChangeOldKey: &'static NSKeyValueChangeKey;
104}
105
106extern "C" {
107 #[cfg(feature = "NSString")]
109 pub static NSKeyValueChangeIndexesKey: &'static NSKeyValueChangeKey;
110}
111
112extern "C" {
113 #[cfg(feature = "NSString")]
115 pub static NSKeyValueChangeNotificationIsPriorKey: &'static NSKeyValueChangeKey;
116}
117
118mod private_NSObjectNSKeyValueObserving {
119 pub trait Sealed {}
120}
121
122#[doc(alias = "NSKeyValueObserving")]
124pub unsafe trait NSObjectNSKeyValueObserving:
125 ClassType + Sized + private_NSObjectNSKeyValueObserving::Sealed
126{
127 extern_methods!(
128 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
129 #[unsafe(method(observeValueForKeyPath:ofObject:change:context:))]
130 #[unsafe(method_family = none)]
131 unsafe fn observeValueForKeyPath_ofObject_change_context(
132 &self,
133 key_path: Option<&NSString>,
134 object: Option<&AnyObject>,
135 change: Option<&NSDictionary<NSKeyValueChangeKey, AnyObject>>,
136 context: *mut c_void,
137 );
138 );
139}
140
141impl private_NSObjectNSKeyValueObserving::Sealed for NSObject {}
142unsafe impl NSObjectNSKeyValueObserving for NSObject {}
143
144mod private_NSObjectNSKeyValueObserverRegistration {
145 pub trait Sealed {}
146}
147
148#[doc(alias = "NSKeyValueObserverRegistration")]
150pub unsafe trait NSObjectNSKeyValueObserverRegistration:
151 ClassType + Sized + private_NSObjectNSKeyValueObserverRegistration::Sealed
152{
153 extern_methods!(
154 #[cfg(feature = "NSString")]
155 #[unsafe(method(addObserver:forKeyPath:options:context:))]
156 #[unsafe(method_family = none)]
157 unsafe fn addObserver_forKeyPath_options_context(
158 &self,
159 observer: &NSObject,
160 key_path: &NSString,
161 options: NSKeyValueObservingOptions,
162 context: *mut c_void,
163 );
164
165 #[cfg(feature = "NSString")]
166 #[unsafe(method(removeObserver:forKeyPath:context:))]
167 #[unsafe(method_family = none)]
168 unsafe fn removeObserver_forKeyPath_context(
169 &self,
170 observer: &NSObject,
171 key_path: &NSString,
172 context: *mut c_void,
173 );
174
175 #[cfg(feature = "NSString")]
176 #[unsafe(method(removeObserver:forKeyPath:))]
177 #[unsafe(method_family = none)]
178 unsafe fn removeObserver_forKeyPath(&self, observer: &NSObject, key_path: &NSString);
179 );
180}
181
182impl private_NSObjectNSKeyValueObserverRegistration::Sealed for NSObject {}
183unsafe impl NSObjectNSKeyValueObserverRegistration for NSObject {}
184
185#[cfg(feature = "NSArray")]
187impl<ObjectType: Message> NSArray<ObjectType> {
188 extern_methods!(
189 #[cfg(all(feature = "NSIndexSet", feature = "NSString"))]
190 #[unsafe(method(addObserver:toObjectsAtIndexes:forKeyPath:options:context:))]
191 #[unsafe(method_family = none)]
192 pub unsafe fn addObserver_toObjectsAtIndexes_forKeyPath_options_context(
193 &self,
194 observer: &NSObject,
195 indexes: &NSIndexSet,
196 key_path: &NSString,
197 options: NSKeyValueObservingOptions,
198 context: *mut c_void,
199 );
200
201 #[cfg(all(feature = "NSIndexSet", feature = "NSString"))]
202 #[unsafe(method(removeObserver:fromObjectsAtIndexes:forKeyPath:context:))]
203 #[unsafe(method_family = none)]
204 pub unsafe fn removeObserver_fromObjectsAtIndexes_forKeyPath_context(
205 &self,
206 observer: &NSObject,
207 indexes: &NSIndexSet,
208 key_path: &NSString,
209 context: *mut c_void,
210 );
211
212 #[cfg(all(feature = "NSIndexSet", feature = "NSString"))]
213 #[unsafe(method(removeObserver:fromObjectsAtIndexes:forKeyPath:))]
214 #[unsafe(method_family = none)]
215 pub unsafe fn removeObserver_fromObjectsAtIndexes_forKeyPath(
216 &self,
217 observer: &NSObject,
218 indexes: &NSIndexSet,
219 key_path: &NSString,
220 );
221
222 #[cfg(feature = "NSString")]
223 #[unsafe(method(addObserver:forKeyPath:options:context:))]
224 #[unsafe(method_family = none)]
225 pub unsafe fn addObserver_forKeyPath_options_context(
226 &self,
227 observer: &NSObject,
228 key_path: &NSString,
229 options: NSKeyValueObservingOptions,
230 context: *mut c_void,
231 );
232
233 #[cfg(feature = "NSString")]
234 #[unsafe(method(removeObserver:forKeyPath:context:))]
235 #[unsafe(method_family = none)]
236 pub unsafe fn removeObserver_forKeyPath_context(
237 &self,
238 observer: &NSObject,
239 key_path: &NSString,
240 context: *mut c_void,
241 );
242
243 #[cfg(feature = "NSString")]
244 #[unsafe(method(removeObserver:forKeyPath:))]
245 #[unsafe(method_family = none)]
246 pub unsafe fn removeObserver_forKeyPath(&self, observer: &NSObject, key_path: &NSString);
247 );
248}
249
250#[cfg(feature = "NSOrderedSet")]
252impl<ObjectType: Message> NSOrderedSet<ObjectType> {
253 extern_methods!(
254 #[cfg(feature = "NSString")]
255 #[unsafe(method(addObserver:forKeyPath:options:context:))]
256 #[unsafe(method_family = none)]
257 pub unsafe fn addObserver_forKeyPath_options_context(
258 &self,
259 observer: &NSObject,
260 key_path: &NSString,
261 options: NSKeyValueObservingOptions,
262 context: *mut c_void,
263 );
264
265 #[cfg(feature = "NSString")]
266 #[unsafe(method(removeObserver:forKeyPath:context:))]
267 #[unsafe(method_family = none)]
268 pub unsafe fn removeObserver_forKeyPath_context(
269 &self,
270 observer: &NSObject,
271 key_path: &NSString,
272 context: *mut c_void,
273 );
274
275 #[cfg(feature = "NSString")]
276 #[unsafe(method(removeObserver:forKeyPath:))]
277 #[unsafe(method_family = none)]
278 pub unsafe fn removeObserver_forKeyPath(&self, observer: &NSObject, key_path: &NSString);
279 );
280}
281
282#[cfg(feature = "NSSet")]
284impl<ObjectType: Message> NSSet<ObjectType> {
285 extern_methods!(
286 #[cfg(feature = "NSString")]
287 #[unsafe(method(addObserver:forKeyPath:options:context:))]
288 #[unsafe(method_family = none)]
289 pub unsafe fn addObserver_forKeyPath_options_context(
290 &self,
291 observer: &NSObject,
292 key_path: &NSString,
293 options: NSKeyValueObservingOptions,
294 context: *mut c_void,
295 );
296
297 #[cfg(feature = "NSString")]
298 #[unsafe(method(removeObserver:forKeyPath:context:))]
299 #[unsafe(method_family = none)]
300 pub unsafe fn removeObserver_forKeyPath_context(
301 &self,
302 observer: &NSObject,
303 key_path: &NSString,
304 context: *mut c_void,
305 );
306
307 #[cfg(feature = "NSString")]
308 #[unsafe(method(removeObserver:forKeyPath:))]
309 #[unsafe(method_family = none)]
310 pub unsafe fn removeObserver_forKeyPath(&self, observer: &NSObject, key_path: &NSString);
311 );
312}
313
314mod private_NSObjectNSKeyValueObserverNotification {
315 pub trait Sealed {}
316}
317
318#[doc(alias = "NSKeyValueObserverNotification")]
320pub unsafe trait NSObjectNSKeyValueObserverNotification:
321 ClassType + Sized + private_NSObjectNSKeyValueObserverNotification::Sealed
322{
323 extern_methods!(
324 #[cfg(feature = "NSString")]
325 #[unsafe(method(willChangeValueForKey:))]
326 #[unsafe(method_family = none)]
327 unsafe fn willChangeValueForKey(&self, key: &NSString);
328
329 #[cfg(feature = "NSString")]
330 #[unsafe(method(didChangeValueForKey:))]
331 #[unsafe(method_family = none)]
332 unsafe fn didChangeValueForKey(&self, key: &NSString);
333
334 #[cfg(all(feature = "NSIndexSet", feature = "NSString"))]
335 #[unsafe(method(willChange:valuesAtIndexes:forKey:))]
336 #[unsafe(method_family = none)]
337 unsafe fn willChange_valuesAtIndexes_forKey(
338 &self,
339 change_kind: NSKeyValueChange,
340 indexes: &NSIndexSet,
341 key: &NSString,
342 );
343
344 #[cfg(all(feature = "NSIndexSet", feature = "NSString"))]
345 #[unsafe(method(didChange:valuesAtIndexes:forKey:))]
346 #[unsafe(method_family = none)]
347 unsafe fn didChange_valuesAtIndexes_forKey(
348 &self,
349 change_kind: NSKeyValueChange,
350 indexes: &NSIndexSet,
351 key: &NSString,
352 );
353
354 #[cfg(all(feature = "NSSet", feature = "NSString"))]
355 #[unsafe(method(willChangeValueForKey:withSetMutation:usingObjects:))]
356 #[unsafe(method_family = none)]
357 unsafe fn willChangeValueForKey_withSetMutation_usingObjects(
358 &self,
359 key: &NSString,
360 mutation_kind: NSKeyValueSetMutationKind,
361 objects: &NSSet,
362 );
363
364 #[cfg(all(feature = "NSSet", feature = "NSString"))]
365 #[unsafe(method(didChangeValueForKey:withSetMutation:usingObjects:))]
366 #[unsafe(method_family = none)]
367 unsafe fn didChangeValueForKey_withSetMutation_usingObjects(
368 &self,
369 key: &NSString,
370 mutation_kind: NSKeyValueSetMutationKind,
371 objects: &NSSet,
372 );
373 );
374}
375
376impl private_NSObjectNSKeyValueObserverNotification::Sealed for NSObject {}
377unsafe impl NSObjectNSKeyValueObserverNotification for NSObject {}
378
379mod private_NSObjectNSKeyValueObservingCustomization {
380 pub trait Sealed {}
381}
382
383#[doc(alias = "NSKeyValueObservingCustomization")]
385pub unsafe trait NSObjectNSKeyValueObservingCustomization:
386 ClassType + Sized + private_NSObjectNSKeyValueObservingCustomization::Sealed
387{
388 extern_methods!(
389 #[cfg(all(feature = "NSSet", feature = "NSString"))]
390 #[unsafe(method(keyPathsForValuesAffectingValueForKey:))]
391 #[unsafe(method_family = none)]
392 unsafe fn keyPathsForValuesAffectingValueForKey(
393 key: &NSString,
394 ) -> Retained<NSSet<NSString>>;
395
396 #[cfg(feature = "NSString")]
397 #[unsafe(method(automaticallyNotifiesObserversForKey:))]
398 #[unsafe(method_family = none)]
399 unsafe fn automaticallyNotifiesObserversForKey(key: &NSString) -> bool;
400
401 #[unsafe(method(observationInfo))]
402 #[unsafe(method_family = none)]
403 unsafe fn observationInfo(&self) -> *mut c_void;
404
405 #[unsafe(method(setObservationInfo:))]
407 #[unsafe(method_family = none)]
408 unsafe fn setObservationInfo(&self, observation_info: *mut c_void);
409 );
410}
411
412impl private_NSObjectNSKeyValueObservingCustomization::Sealed for NSObject {}
413unsafe impl NSObjectNSKeyValueObservingCustomization for NSObject {}