objc2_foundation/generated/
NSKeyValueObserving.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nskeyvalueobservingoptions?language=objc)
10// NS_OPTIONS
11#[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/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nskeyvaluechange?language=objc)
36// NS_ENUM
37#[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/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nskeyvaluesetmutationkind?language=objc)
60// NS_ENUM
61#[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/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nskeyvaluechangekey?language=objc)
84// NS_TYPED_ENUM
85#[cfg(feature = "NSString")]
86pub type NSKeyValueChangeKey = NSString;
87
88extern "C" {
89    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nskeyvaluechangekindkey?language=objc)
90    #[cfg(feature = "NSString")]
91    pub static NSKeyValueChangeKindKey: &'static NSKeyValueChangeKey;
92}
93
94extern "C" {
95    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nskeyvaluechangenewkey?language=objc)
96    #[cfg(feature = "NSString")]
97    pub static NSKeyValueChangeNewKey: &'static NSKeyValueChangeKey;
98}
99
100extern "C" {
101    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nskeyvaluechangeoldkey?language=objc)
102    #[cfg(feature = "NSString")]
103    pub static NSKeyValueChangeOldKey: &'static NSKeyValueChangeKey;
104}
105
106extern "C" {
107    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nskeyvaluechangeindexeskey?language=objc)
108    #[cfg(feature = "NSString")]
109    pub static NSKeyValueChangeIndexesKey: &'static NSKeyValueChangeKey;
110}
111
112extern "C" {
113    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nskeyvaluechangenotificationispriorkey?language=objc)
114    #[cfg(feature = "NSString")]
115    pub static NSKeyValueChangeNotificationIsPriorKey: &'static NSKeyValueChangeKey;
116}
117
118mod private_NSObjectNSKeyValueObserving {
119    pub trait Sealed {}
120}
121
122/// Category "NSKeyValueObserving" on [`NSObject`].
123#[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        /// # Safety
130        ///
131        /// - `object` should be of the correct type.
132        /// - `change` generic should be of the correct type.
133        /// - `context` must be a valid pointer or null.
134        #[unsafe(method(observeValueForKeyPath:ofObject:change:context:))]
135        #[unsafe(method_family = none)]
136        unsafe fn observeValueForKeyPath_ofObject_change_context(
137            &self,
138            key_path: Option<&NSString>,
139            object: Option<&AnyObject>,
140            change: Option<&NSDictionary<NSKeyValueChangeKey, AnyObject>>,
141            context: *mut c_void,
142        );
143    );
144}
145
146impl private_NSObjectNSKeyValueObserving::Sealed for NSObject {}
147unsafe impl NSObjectNSKeyValueObserving for NSObject {}
148
149mod private_NSObjectNSKeyValueObserverRegistration {
150    pub trait Sealed {}
151}
152
153/// Category "NSKeyValueObserverRegistration" on [`NSObject`].
154#[doc(alias = "NSKeyValueObserverRegistration")]
155pub unsafe trait NSObjectNSKeyValueObserverRegistration:
156    ClassType + Sized + private_NSObjectNSKeyValueObserverRegistration::Sealed
157{
158    extern_methods!(
159        #[cfg(feature = "NSString")]
160        /// # Safety
161        ///
162        /// - `observer` should be of the correct type.
163        /// - `context` must be a valid pointer or null.
164        #[unsafe(method(addObserver:forKeyPath:options:context:))]
165        #[unsafe(method_family = none)]
166        unsafe fn addObserver_forKeyPath_options_context(
167            &self,
168            observer: &NSObject,
169            key_path: &NSString,
170            options: NSKeyValueObservingOptions,
171            context: *mut c_void,
172        );
173
174        #[cfg(feature = "NSString")]
175        /// # Safety
176        ///
177        /// - `observer` should be of the correct type.
178        /// - `context` must be a valid pointer or null.
179        #[unsafe(method(removeObserver:forKeyPath:context:))]
180        #[unsafe(method_family = none)]
181        unsafe fn removeObserver_forKeyPath_context(
182            &self,
183            observer: &NSObject,
184            key_path: &NSString,
185            context: *mut c_void,
186        );
187
188        #[cfg(feature = "NSString")]
189        /// # Safety
190        ///
191        /// `observer` should be of the correct type.
192        #[unsafe(method(removeObserver:forKeyPath:))]
193        #[unsafe(method_family = none)]
194        unsafe fn removeObserver_forKeyPath(&self, observer: &NSObject, key_path: &NSString);
195    );
196}
197
198impl private_NSObjectNSKeyValueObserverRegistration::Sealed for NSObject {}
199unsafe impl NSObjectNSKeyValueObserverRegistration for NSObject {}
200
201/// NSKeyValueObserverRegistration.
202#[cfg(feature = "NSArray")]
203impl<ObjectType: Message> NSArray<ObjectType> {
204    extern_methods!(
205        #[cfg(all(feature = "NSIndexSet", feature = "NSString"))]
206        /// # Safety
207        ///
208        /// - `observer` should be of the correct type.
209        /// - `context` must be a valid pointer or null.
210        #[unsafe(method(addObserver:toObjectsAtIndexes:forKeyPath:options:context:))]
211        #[unsafe(method_family = none)]
212        pub unsafe fn addObserver_toObjectsAtIndexes_forKeyPath_options_context(
213            &self,
214            observer: &NSObject,
215            indexes: &NSIndexSet,
216            key_path: &NSString,
217            options: NSKeyValueObservingOptions,
218            context: *mut c_void,
219        );
220
221        #[cfg(all(feature = "NSIndexSet", feature = "NSString"))]
222        /// # Safety
223        ///
224        /// - `observer` should be of the correct type.
225        /// - `context` must be a valid pointer or null.
226        #[unsafe(method(removeObserver:fromObjectsAtIndexes:forKeyPath:context:))]
227        #[unsafe(method_family = none)]
228        pub unsafe fn removeObserver_fromObjectsAtIndexes_forKeyPath_context(
229            &self,
230            observer: &NSObject,
231            indexes: &NSIndexSet,
232            key_path: &NSString,
233            context: *mut c_void,
234        );
235
236        #[cfg(all(feature = "NSIndexSet", feature = "NSString"))]
237        /// # Safety
238        ///
239        /// `observer` should be of the correct type.
240        #[unsafe(method(removeObserver:fromObjectsAtIndexes:forKeyPath:))]
241        #[unsafe(method_family = none)]
242        pub unsafe fn removeObserver_fromObjectsAtIndexes_forKeyPath(
243            &self,
244            observer: &NSObject,
245            indexes: &NSIndexSet,
246            key_path: &NSString,
247        );
248
249        #[cfg(feature = "NSString")]
250        /// # Safety
251        ///
252        /// - `observer` should be of the correct type.
253        /// - `context` must be a valid pointer or null.
254        #[unsafe(method(addObserver:forKeyPath:options:context:))]
255        #[unsafe(method_family = none)]
256        pub unsafe fn addObserver_forKeyPath_options_context(
257            &self,
258            observer: &NSObject,
259            key_path: &NSString,
260            options: NSKeyValueObservingOptions,
261            context: *mut c_void,
262        );
263
264        #[cfg(feature = "NSString")]
265        /// # Safety
266        ///
267        /// - `observer` should be of the correct type.
268        /// - `context` must be a valid pointer or null.
269        #[unsafe(method(removeObserver:forKeyPath:context:))]
270        #[unsafe(method_family = none)]
271        pub unsafe fn removeObserver_forKeyPath_context(
272            &self,
273            observer: &NSObject,
274            key_path: &NSString,
275            context: *mut c_void,
276        );
277
278        #[cfg(feature = "NSString")]
279        /// # Safety
280        ///
281        /// `observer` should be of the correct type.
282        #[unsafe(method(removeObserver:forKeyPath:))]
283        #[unsafe(method_family = none)]
284        pub unsafe fn removeObserver_forKeyPath(&self, observer: &NSObject, key_path: &NSString);
285    );
286}
287
288/// NSKeyValueObserverRegistration.
289#[cfg(feature = "NSOrderedSet")]
290impl<ObjectType: Message> NSOrderedSet<ObjectType> {
291    extern_methods!(
292        #[cfg(feature = "NSString")]
293        /// # Safety
294        ///
295        /// - `observer` should be of the correct type.
296        /// - `context` must be a valid pointer or null.
297        #[unsafe(method(addObserver:forKeyPath:options:context:))]
298        #[unsafe(method_family = none)]
299        pub unsafe fn addObserver_forKeyPath_options_context(
300            &self,
301            observer: &NSObject,
302            key_path: &NSString,
303            options: NSKeyValueObservingOptions,
304            context: *mut c_void,
305        );
306
307        #[cfg(feature = "NSString")]
308        /// # Safety
309        ///
310        /// - `observer` should be of the correct type.
311        /// - `context` must be a valid pointer or null.
312        #[unsafe(method(removeObserver:forKeyPath:context:))]
313        #[unsafe(method_family = none)]
314        pub unsafe fn removeObserver_forKeyPath_context(
315            &self,
316            observer: &NSObject,
317            key_path: &NSString,
318            context: *mut c_void,
319        );
320
321        #[cfg(feature = "NSString")]
322        /// # Safety
323        ///
324        /// `observer` should be of the correct type.
325        #[unsafe(method(removeObserver:forKeyPath:))]
326        #[unsafe(method_family = none)]
327        pub unsafe fn removeObserver_forKeyPath(&self, observer: &NSObject, key_path: &NSString);
328    );
329}
330
331/// NSKeyValueObserverRegistration.
332#[cfg(feature = "NSSet")]
333impl<ObjectType: Message> NSSet<ObjectType> {
334    extern_methods!(
335        #[cfg(feature = "NSString")]
336        /// # Safety
337        ///
338        /// - `observer` should be of the correct type.
339        /// - `context` must be a valid pointer or null.
340        #[unsafe(method(addObserver:forKeyPath:options:context:))]
341        #[unsafe(method_family = none)]
342        pub unsafe fn addObserver_forKeyPath_options_context(
343            &self,
344            observer: &NSObject,
345            key_path: &NSString,
346            options: NSKeyValueObservingOptions,
347            context: *mut c_void,
348        );
349
350        #[cfg(feature = "NSString")]
351        /// # Safety
352        ///
353        /// - `observer` should be of the correct type.
354        /// - `context` must be a valid pointer or null.
355        #[unsafe(method(removeObserver:forKeyPath:context:))]
356        #[unsafe(method_family = none)]
357        pub unsafe fn removeObserver_forKeyPath_context(
358            &self,
359            observer: &NSObject,
360            key_path: &NSString,
361            context: *mut c_void,
362        );
363
364        #[cfg(feature = "NSString")]
365        /// # Safety
366        ///
367        /// `observer` should be of the correct type.
368        #[unsafe(method(removeObserver:forKeyPath:))]
369        #[unsafe(method_family = none)]
370        pub unsafe fn removeObserver_forKeyPath(&self, observer: &NSObject, key_path: &NSString);
371    );
372}
373
374mod private_NSObjectNSKeyValueObserverNotification {
375    pub trait Sealed {}
376}
377
378/// Category "NSKeyValueObserverNotification" on [`NSObject`].
379#[doc(alias = "NSKeyValueObserverNotification")]
380pub unsafe trait NSObjectNSKeyValueObserverNotification:
381    ClassType + Sized + private_NSObjectNSKeyValueObserverNotification::Sealed
382{
383    extern_methods!(
384        #[cfg(feature = "NSString")]
385        #[unsafe(method(willChangeValueForKey:))]
386        #[unsafe(method_family = none)]
387        fn willChangeValueForKey(&self, key: &NSString);
388
389        #[cfg(feature = "NSString")]
390        #[unsafe(method(didChangeValueForKey:))]
391        #[unsafe(method_family = none)]
392        fn didChangeValueForKey(&self, key: &NSString);
393
394        #[cfg(all(feature = "NSIndexSet", feature = "NSString"))]
395        #[unsafe(method(willChange:valuesAtIndexes:forKey:))]
396        #[unsafe(method_family = none)]
397        fn willChange_valuesAtIndexes_forKey(
398            &self,
399            change_kind: NSKeyValueChange,
400            indexes: &NSIndexSet,
401            key: &NSString,
402        );
403
404        #[cfg(all(feature = "NSIndexSet", feature = "NSString"))]
405        #[unsafe(method(didChange:valuesAtIndexes:forKey:))]
406        #[unsafe(method_family = none)]
407        fn didChange_valuesAtIndexes_forKey(
408            &self,
409            change_kind: NSKeyValueChange,
410            indexes: &NSIndexSet,
411            key: &NSString,
412        );
413
414        #[cfg(all(feature = "NSSet", feature = "NSString"))]
415        /// # Safety
416        ///
417        /// `objects` generic should be of the correct type.
418        #[unsafe(method(willChangeValueForKey:withSetMutation:usingObjects:))]
419        #[unsafe(method_family = none)]
420        unsafe fn willChangeValueForKey_withSetMutation_usingObjects(
421            &self,
422            key: &NSString,
423            mutation_kind: NSKeyValueSetMutationKind,
424            objects: &NSSet,
425        );
426
427        #[cfg(all(feature = "NSSet", feature = "NSString"))]
428        /// # Safety
429        ///
430        /// `objects` generic should be of the correct type.
431        #[unsafe(method(didChangeValueForKey:withSetMutation:usingObjects:))]
432        #[unsafe(method_family = none)]
433        unsafe fn didChangeValueForKey_withSetMutation_usingObjects(
434            &self,
435            key: &NSString,
436            mutation_kind: NSKeyValueSetMutationKind,
437            objects: &NSSet,
438        );
439    );
440}
441
442impl private_NSObjectNSKeyValueObserverNotification::Sealed for NSObject {}
443unsafe impl NSObjectNSKeyValueObserverNotification for NSObject {}
444
445mod private_NSObjectNSKeyValueObservingCustomization {
446    pub trait Sealed {}
447}
448
449/// Category "NSKeyValueObservingCustomization" on [`NSObject`].
450#[doc(alias = "NSKeyValueObservingCustomization")]
451pub unsafe trait NSObjectNSKeyValueObservingCustomization:
452    ClassType + Sized + private_NSObjectNSKeyValueObservingCustomization::Sealed
453{
454    extern_methods!(
455        #[cfg(all(feature = "NSSet", feature = "NSString"))]
456        #[unsafe(method(keyPathsForValuesAffectingValueForKey:))]
457        #[unsafe(method_family = none)]
458        fn keyPathsForValuesAffectingValueForKey(key: &NSString) -> Retained<NSSet<NSString>>;
459
460        #[cfg(feature = "NSString")]
461        #[unsafe(method(automaticallyNotifiesObserversForKey:))]
462        #[unsafe(method_family = none)]
463        fn automaticallyNotifiesObserversForKey(key: &NSString) -> bool;
464
465        #[unsafe(method(observationInfo))]
466        #[unsafe(method_family = none)]
467        fn observationInfo(&self) -> *mut c_void;
468
469        /// Setter for [`observationInfo`][Self::observationInfo].
470        ///
471        /// # Safety
472        ///
473        /// `observation_info` must be a valid pointer or null.
474        #[unsafe(method(setObservationInfo:))]
475        #[unsafe(method_family = none)]
476        unsafe fn setObservationInfo(&self, observation_info: *mut c_void);
477    );
478}
479
480impl private_NSObjectNSKeyValueObservingCustomization::Sealed for NSObject {}
481unsafe impl NSObjectNSKeyValueObservingCustomization for NSObject {}