objc2_foundation/generated/
NSKeyValueCoding.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
9extern "C" {
10    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsundefinedkeyexception?language=objc)
11    #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
12    pub static NSUndefinedKeyException: &'static NSExceptionName;
13}
14
15/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nskeyvalueoperator?language=objc)
16// NS_TYPED_ENUM
17#[cfg(feature = "NSString")]
18pub type NSKeyValueOperator = NSString;
19
20extern "C" {
21    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsaveragekeyvalueoperator?language=objc)
22    #[cfg(feature = "NSString")]
23    pub static NSAverageKeyValueOperator: &'static NSKeyValueOperator;
24}
25
26extern "C" {
27    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscountkeyvalueoperator?language=objc)
28    #[cfg(feature = "NSString")]
29    pub static NSCountKeyValueOperator: &'static NSKeyValueOperator;
30}
31
32extern "C" {
33    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdistinctunionofarrayskeyvalueoperator?language=objc)
34    #[cfg(feature = "NSString")]
35    pub static NSDistinctUnionOfArraysKeyValueOperator: &'static NSKeyValueOperator;
36}
37
38extern "C" {
39    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdistinctunionofobjectskeyvalueoperator?language=objc)
40    #[cfg(feature = "NSString")]
41    pub static NSDistinctUnionOfObjectsKeyValueOperator: &'static NSKeyValueOperator;
42}
43
44extern "C" {
45    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdistinctunionofsetskeyvalueoperator?language=objc)
46    #[cfg(feature = "NSString")]
47    pub static NSDistinctUnionOfSetsKeyValueOperator: &'static NSKeyValueOperator;
48}
49
50extern "C" {
51    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmaximumkeyvalueoperator?language=objc)
52    #[cfg(feature = "NSString")]
53    pub static NSMaximumKeyValueOperator: &'static NSKeyValueOperator;
54}
55
56extern "C" {
57    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsminimumkeyvalueoperator?language=objc)
58    #[cfg(feature = "NSString")]
59    pub static NSMinimumKeyValueOperator: &'static NSKeyValueOperator;
60}
61
62extern "C" {
63    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nssumkeyvalueoperator?language=objc)
64    #[cfg(feature = "NSString")]
65    pub static NSSumKeyValueOperator: &'static NSKeyValueOperator;
66}
67
68extern "C" {
69    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsunionofarrayskeyvalueoperator?language=objc)
70    #[cfg(feature = "NSString")]
71    pub static NSUnionOfArraysKeyValueOperator: &'static NSKeyValueOperator;
72}
73
74extern "C" {
75    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsunionofobjectskeyvalueoperator?language=objc)
76    #[cfg(feature = "NSString")]
77    pub static NSUnionOfObjectsKeyValueOperator: &'static NSKeyValueOperator;
78}
79
80extern "C" {
81    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsunionofsetskeyvalueoperator?language=objc)
82    #[cfg(feature = "NSString")]
83    pub static NSUnionOfSetsKeyValueOperator: &'static NSKeyValueOperator;
84}
85
86mod private_NSObjectNSKeyValueCoding {
87    pub trait Sealed {}
88}
89
90/// Category "NSKeyValueCoding" on [`NSObject`].
91#[doc(alias = "NSKeyValueCoding")]
92pub unsafe trait NSObjectNSKeyValueCoding:
93    ClassType + Sized + private_NSObjectNSKeyValueCoding::Sealed
94{
95    extern_methods!(
96        #[unsafe(method(accessInstanceVariablesDirectly))]
97        #[unsafe(method_family = none)]
98        fn accessInstanceVariablesDirectly() -> bool;
99
100        #[cfg(feature = "NSString")]
101        #[unsafe(method(valueForKey:))]
102        #[unsafe(method_family = none)]
103        fn valueForKey(&self, key: &NSString) -> Option<Retained<AnyObject>>;
104
105        #[cfg(feature = "NSString")]
106        /// # Safety
107        ///
108        /// `value` should be of the correct type.
109        #[unsafe(method(setValue:forKey:))]
110        #[unsafe(method_family = none)]
111        unsafe fn setValue_forKey(&self, value: Option<&AnyObject>, key: &NSString);
112
113        #[cfg(all(feature = "NSError", feature = "NSString"))]
114        /// # Safety
115        ///
116        /// `io_value` should be of the correct type.
117        #[unsafe(method(validateValue:forKey:error:_))]
118        #[unsafe(method_family = none)]
119        unsafe fn validateValue_forKey_error(
120            &self,
121            io_value: &mut Option<Retained<AnyObject>>,
122            in_key: &NSString,
123        ) -> Result<(), Retained<NSError>>;
124
125        #[cfg(all(feature = "NSArray", feature = "NSString"))]
126        /// # Safety
127        ///
128        /// The returned generic should be of the correct type.
129        #[unsafe(method(mutableArrayValueForKey:))]
130        #[unsafe(method_family = none)]
131        unsafe fn mutableArrayValueForKey(&self, key: &NSString) -> Retained<NSMutableArray>;
132
133        #[cfg(all(feature = "NSOrderedSet", feature = "NSString"))]
134        /// # Safety
135        ///
136        /// The returned generic should be of the correct type.
137        #[unsafe(method(mutableOrderedSetValueForKey:))]
138        #[unsafe(method_family = none)]
139        unsafe fn mutableOrderedSetValueForKey(
140            &self,
141            key: &NSString,
142        ) -> Retained<NSMutableOrderedSet>;
143
144        #[cfg(all(feature = "NSSet", feature = "NSString"))]
145        /// # Safety
146        ///
147        /// The returned generic should be of the correct type.
148        #[unsafe(method(mutableSetValueForKey:))]
149        #[unsafe(method_family = none)]
150        unsafe fn mutableSetValueForKey(&self, key: &NSString) -> Retained<NSMutableSet>;
151
152        #[cfg(feature = "NSString")]
153        #[unsafe(method(valueForKeyPath:))]
154        #[unsafe(method_family = none)]
155        fn valueForKeyPath(&self, key_path: &NSString) -> Option<Retained<AnyObject>>;
156
157        #[cfg(feature = "NSString")]
158        /// # Safety
159        ///
160        /// `value` should be of the correct type.
161        #[unsafe(method(setValue:forKeyPath:))]
162        #[unsafe(method_family = none)]
163        unsafe fn setValue_forKeyPath(&self, value: Option<&AnyObject>, key_path: &NSString);
164
165        #[cfg(all(feature = "NSError", feature = "NSString"))]
166        /// # Safety
167        ///
168        /// `io_value` should be of the correct type.
169        #[unsafe(method(validateValue:forKeyPath:error:_))]
170        #[unsafe(method_family = none)]
171        unsafe fn validateValue_forKeyPath_error(
172            &self,
173            io_value: &mut Option<Retained<AnyObject>>,
174            in_key_path: &NSString,
175        ) -> Result<(), Retained<NSError>>;
176
177        #[cfg(all(feature = "NSArray", feature = "NSString"))]
178        /// # Safety
179        ///
180        /// The returned generic should be of the correct type.
181        #[unsafe(method(mutableArrayValueForKeyPath:))]
182        #[unsafe(method_family = none)]
183        unsafe fn mutableArrayValueForKeyPath(
184            &self,
185            key_path: &NSString,
186        ) -> Retained<NSMutableArray>;
187
188        #[cfg(all(feature = "NSOrderedSet", feature = "NSString"))]
189        /// # Safety
190        ///
191        /// The returned generic should be of the correct type.
192        #[unsafe(method(mutableOrderedSetValueForKeyPath:))]
193        #[unsafe(method_family = none)]
194        unsafe fn mutableOrderedSetValueForKeyPath(
195            &self,
196            key_path: &NSString,
197        ) -> Retained<NSMutableOrderedSet>;
198
199        #[cfg(all(feature = "NSSet", feature = "NSString"))]
200        /// # Safety
201        ///
202        /// The returned generic should be of the correct type.
203        #[unsafe(method(mutableSetValueForKeyPath:))]
204        #[unsafe(method_family = none)]
205        unsafe fn mutableSetValueForKeyPath(&self, key_path: &NSString) -> Retained<NSMutableSet>;
206
207        #[cfg(feature = "NSString")]
208        #[unsafe(method(valueForUndefinedKey:))]
209        #[unsafe(method_family = none)]
210        fn valueForUndefinedKey(&self, key: &NSString) -> Option<Retained<AnyObject>>;
211
212        #[cfg(feature = "NSString")]
213        /// # Safety
214        ///
215        /// `value` should be of the correct type.
216        #[unsafe(method(setValue:forUndefinedKey:))]
217        #[unsafe(method_family = none)]
218        unsafe fn setValue_forUndefinedKey(&self, value: Option<&AnyObject>, key: &NSString);
219
220        #[cfg(feature = "NSString")]
221        #[unsafe(method(setNilValueForKey:))]
222        #[unsafe(method_family = none)]
223        unsafe fn setNilValueForKey(&self, key: &NSString);
224
225        #[cfg(all(feature = "NSArray", feature = "NSDictionary", feature = "NSString"))]
226        #[unsafe(method(dictionaryWithValuesForKeys:))]
227        #[unsafe(method_family = none)]
228        fn dictionaryWithValuesForKeys(
229            &self,
230            keys: &NSArray<NSString>,
231        ) -> Retained<NSDictionary<NSString, AnyObject>>;
232
233        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
234        /// # Safety
235        ///
236        /// `keyed_values` generic should be of the correct type.
237        #[unsafe(method(setValuesForKeysWithDictionary:))]
238        #[unsafe(method_family = none)]
239        unsafe fn setValuesForKeysWithDictionary(
240            &self,
241            keyed_values: &NSDictionary<NSString, AnyObject>,
242        );
243    );
244}
245
246impl private_NSObjectNSKeyValueCoding::Sealed for NSObject {}
247unsafe impl NSObjectNSKeyValueCoding for NSObject {}
248
249/// NSKeyValueCoding.
250#[cfg(feature = "NSArray")]
251impl<ObjectType: Message> NSArray<ObjectType> {
252    extern_methods!(
253        #[cfg(feature = "NSString")]
254        #[unsafe(method(valueForKey:))]
255        #[unsafe(method_family = none)]
256        pub fn valueForKey(&self, key: &NSString) -> Retained<AnyObject>;
257
258        #[cfg(feature = "NSString")]
259        /// # Safety
260        ///
261        /// `value` should be of the correct type.
262        #[unsafe(method(setValue:forKey:))]
263        #[unsafe(method_family = none)]
264        pub unsafe fn setValue_forKey(&self, value: Option<&AnyObject>, key: &NSString);
265    );
266}
267
268/// NSKeyValueCoding.
269#[cfg(feature = "NSDictionary")]
270impl<KeyType: Message, ObjectType: Message> NSDictionary<KeyType, ObjectType> {
271    extern_methods!(
272        #[cfg(feature = "NSString")]
273        #[unsafe(method(valueForKey:))]
274        #[unsafe(method_family = none)]
275        pub fn valueForKey(&self, key: &NSString) -> Option<Retained<ObjectType>>;
276    );
277}
278
279/// NSKeyValueCoding.
280#[cfg(feature = "NSDictionary")]
281impl<KeyType: Message, ObjectType: Message> NSMutableDictionary<KeyType, ObjectType> {
282    extern_methods!(
283        #[cfg(feature = "NSString")]
284        #[unsafe(method(setValue:forKey:))]
285        #[unsafe(method_family = none)]
286        pub unsafe fn setValue_forKey(&self, value: Option<&ObjectType>, key: &NSString);
287    );
288}
289
290/// NSKeyValueCoding.
291#[cfg(feature = "NSOrderedSet")]
292impl<ObjectType: Message> NSOrderedSet<ObjectType> {
293    extern_methods!(
294        #[cfg(feature = "NSString")]
295        #[unsafe(method(valueForKey:))]
296        #[unsafe(method_family = none)]
297        pub fn valueForKey(&self, key: &NSString) -> Retained<AnyObject>;
298
299        #[cfg(feature = "NSString")]
300        /// # Safety
301        ///
302        /// `value` should be of the correct type.
303        #[unsafe(method(setValue:forKey:))]
304        #[unsafe(method_family = none)]
305        pub unsafe fn setValue_forKey(&self, value: Option<&AnyObject>, key: &NSString);
306    );
307}
308
309/// NSKeyValueCoding.
310#[cfg(feature = "NSSet")]
311impl<ObjectType: Message> NSSet<ObjectType> {
312    extern_methods!(
313        #[cfg(feature = "NSString")]
314        #[unsafe(method(valueForKey:))]
315        #[unsafe(method_family = none)]
316        pub fn valueForKey(&self, key: &NSString) -> Retained<AnyObject>;
317
318        #[cfg(feature = "NSString")]
319        /// # Safety
320        ///
321        /// `value` should be of the correct type.
322        #[unsafe(method(setValue:forKey:))]
323        #[unsafe(method_family = none)]
324        pub unsafe fn setValue_forKey(&self, value: Option<&AnyObject>, key: &NSString);
325    );
326}