objc2_foundation/generated/
NSKeyedArchiver.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/nsinvalidarchiveoperationexception?language=objc)
11    #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
12    pub static NSInvalidArchiveOperationException: &'static NSExceptionName;
13}
14
15extern "C" {
16    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsinvalidunarchiveoperationexception?language=objc)
17    #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
18    pub static NSInvalidUnarchiveOperationException: &'static NSExceptionName;
19}
20
21extern "C" {
22    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nskeyedarchiverootobjectkey?language=objc)
23    #[cfg(feature = "NSString")]
24    pub static NSKeyedArchiveRootObjectKey: &'static NSString;
25}
26
27extern_class!(
28    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nskeyedarchiver?language=objc)
29    #[unsafe(super(NSCoder, NSObject))]
30    #[derive(Debug, PartialEq, Eq, Hash)]
31    #[cfg(feature = "NSCoder")]
32    pub struct NSKeyedArchiver;
33);
34
35#[cfg(feature = "NSCoder")]
36extern_conformance!(
37    unsafe impl NSObjectProtocol for NSKeyedArchiver {}
38);
39
40#[cfg(feature = "NSCoder")]
41impl NSKeyedArchiver {
42    extern_methods!(
43        /// Initializes the receiver for encoding an archive, optionally disabling secure coding.
44        ///
45        /// If
46        /// `NSSecureCoding`cannot be used,
47        /// `requiresSecureCoding`may be turned off here; for improved security, however,
48        /// `requiresSecureCoding`should be left enabled whenever possible.
49        /// `requiresSecureCoding`ensures that all encoded objects conform to
50        /// `NSSecureCoding,`preventing the possibility of encoding objects which cannot be decoded later.
51        ///
52        /// To produce archives whose structure matches those previously encoded using
53        /// `+archivedDataWithRootObject,`encode the top-level object in your archive for the
54        /// `NSKeyedArchiveRootObjectKey.`
55        #[unsafe(method(initRequiringSecureCoding:))]
56        #[unsafe(method_family = init)]
57        pub fn initRequiringSecureCoding(
58            this: Allocated<Self>,
59            requires_secure_coding: bool,
60        ) -> Retained<Self>;
61
62        #[cfg(all(feature = "NSData", feature = "NSError"))]
63        /// Returns an
64        /// `NSData`object containing the encoded form of the object graph whose root object is given, optionally disabling secure coding.
65        ///
66        /// If
67        /// `NSSecureCoding`cannot be used,
68        /// `requiresSecureCoding`may be turned off here; for improved security, however,
69        /// `requiresSecureCoding`should be left enabled whenever possible.
70        /// `requiresSecureCoding`ensures that all encoded objects conform to
71        /// `NSSecureCoding,`preventing the possibility of encoding objects which cannot be decoded later.
72        ///
73        /// If the object graph cannot be encoded, returns
74        /// `nil`and sets the
75        /// `error`out parameter.
76        ///
77        /// # Safety
78        ///
79        /// `object` should be of the correct type.
80        #[unsafe(method(archivedDataWithRootObject:requiringSecureCoding:error:_))]
81        #[unsafe(method_family = none)]
82        pub unsafe fn archivedDataWithRootObject_requiringSecureCoding_error(
83            object: &AnyObject,
84            requires_secure_coding: bool,
85        ) -> Result<Retained<NSData>, Retained<NSError>>;
86
87        /// Initialize the archiver with empty data, ready for writing.
88        #[deprecated = "Use -initRequiringSecureCoding: instead"]
89        #[unsafe(method(init))]
90        #[unsafe(method_family = init)]
91        pub fn init(this: Allocated<Self>) -> Retained<Self>;
92
93        #[cfg(feature = "NSData")]
94        #[deprecated = "Use -initRequiringSecureCoding: instead"]
95        #[unsafe(method(initForWritingWithMutableData:))]
96        #[unsafe(method_family = init)]
97        pub fn initForWritingWithMutableData(
98            this: Allocated<Self>,
99            data: &NSMutableData,
100        ) -> Retained<Self>;
101
102        #[cfg(feature = "NSData")]
103        /// # Safety
104        ///
105        /// `root_object` should be of the correct type.
106        #[deprecated = "Use +archivedDataWithRootObject:requiringSecureCoding:error: instead"]
107        #[unsafe(method(archivedDataWithRootObject:))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn archivedDataWithRootObject(root_object: &AnyObject) -> Retained<NSData>;
110
111        #[cfg(feature = "NSString")]
112        /// # Safety
113        ///
114        /// `root_object` should be of the correct type.
115        #[deprecated = "Use +archivedDataWithRootObject:requiringSecureCoding:error: and -writeToURL:options:error: instead"]
116        #[unsafe(method(archiveRootObject:toFile:))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn archiveRootObject_toFile(root_object: &AnyObject, path: &NSString) -> bool;
119
120        /// # Safety
121        ///
122        /// This is not retained internally, you must ensure the object is still alive.
123        #[unsafe(method(delegate))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn delegate(
126            &self,
127        ) -> Option<Retained<ProtocolObject<dyn NSKeyedArchiverDelegate>>>;
128
129        /// Setter for [`delegate`][Self::delegate].
130        ///
131        /// # Safety
132        ///
133        /// This is unretained, you must ensure the object is kept alive while in use.
134        #[unsafe(method(setDelegate:))]
135        #[unsafe(method_family = none)]
136        pub unsafe fn setDelegate(
137            &self,
138            delegate: Option<&ProtocolObject<dyn NSKeyedArchiverDelegate>>,
139        );
140
141        #[cfg(feature = "NSPropertyList")]
142        #[unsafe(method(outputFormat))]
143        #[unsafe(method_family = none)]
144        pub fn outputFormat(&self) -> NSPropertyListFormat;
145
146        #[cfg(feature = "NSPropertyList")]
147        /// Setter for [`outputFormat`][Self::outputFormat].
148        #[unsafe(method(setOutputFormat:))]
149        #[unsafe(method_family = none)]
150        pub fn setOutputFormat(&self, output_format: NSPropertyListFormat);
151
152        #[cfg(feature = "NSData")]
153        /// If encoding has not yet finished, then invoking this property will call finishEncoding and return the data. If you initialized the keyed archiver with a specific mutable data instance, then it will be returned from this property after finishEncoding is called.
154        #[unsafe(method(encodedData))]
155        #[unsafe(method_family = none)]
156        pub fn encodedData(&self) -> Retained<NSData>;
157
158        #[unsafe(method(finishEncoding))]
159        #[unsafe(method_family = none)]
160        pub fn finishEncoding(&self);
161
162        #[cfg(feature = "NSString")]
163        /// # Safety
164        ///
165        /// `cls` probably has further requirements.
166        #[unsafe(method(setClassName:forClass:))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn setClassName_forClass_class(coded_name: Option<&NSString>, cls: &AnyClass);
169
170        #[cfg(feature = "NSString")]
171        /// # Safety
172        ///
173        /// `cls` probably has further requirements.
174        #[unsafe(method(setClassName:forClass:))]
175        #[unsafe(method_family = none)]
176        pub unsafe fn setClassName_forClass(&self, coded_name: Option<&NSString>, cls: &AnyClass);
177
178        #[cfg(feature = "NSString")]
179        /// # Safety
180        ///
181        /// `cls` probably has further requirements.
182        #[unsafe(method(classNameForClass:))]
183        #[unsafe(method_family = none)]
184        pub unsafe fn classNameForClass_class(cls: &AnyClass) -> Option<Retained<NSString>>;
185
186        #[cfg(feature = "NSString")]
187        /// # Safety
188        ///
189        /// `cls` probably has further requirements.
190        #[unsafe(method(classNameForClass:))]
191        #[unsafe(method_family = none)]
192        pub unsafe fn classNameForClass(&self, cls: &AnyClass) -> Option<Retained<NSString>>;
193
194        #[cfg(feature = "NSString")]
195        /// # Safety
196        ///
197        /// `object` should be of the correct type.
198        #[unsafe(method(encodeObject:forKey:))]
199        #[unsafe(method_family = none)]
200        pub unsafe fn encodeObject_forKey(&self, object: Option<&AnyObject>, key: &NSString);
201
202        #[cfg(feature = "NSString")]
203        /// # Safety
204        ///
205        /// `object` should be of the correct type.
206        #[unsafe(method(encodeConditionalObject:forKey:))]
207        #[unsafe(method_family = none)]
208        pub unsafe fn encodeConditionalObject_forKey(
209            &self,
210            object: Option<&AnyObject>,
211            key: &NSString,
212        );
213
214        #[cfg(feature = "NSString")]
215        #[unsafe(method(encodeBool:forKey:))]
216        #[unsafe(method_family = none)]
217        pub fn encodeBool_forKey(&self, value: bool, key: &NSString);
218
219        #[cfg(feature = "NSString")]
220        #[unsafe(method(encodeInt:forKey:))]
221        #[unsafe(method_family = none)]
222        pub fn encodeInt_forKey(&self, value: c_int, key: &NSString);
223
224        #[cfg(feature = "NSString")]
225        #[unsafe(method(encodeInt32:forKey:))]
226        #[unsafe(method_family = none)]
227        pub fn encodeInt32_forKey(&self, value: i32, key: &NSString);
228
229        #[cfg(feature = "NSString")]
230        #[unsafe(method(encodeInt64:forKey:))]
231        #[unsafe(method_family = none)]
232        pub fn encodeInt64_forKey(&self, value: i64, key: &NSString);
233
234        #[cfg(feature = "NSString")]
235        #[unsafe(method(encodeFloat:forKey:))]
236        #[unsafe(method_family = none)]
237        pub fn encodeFloat_forKey(&self, value: c_float, key: &NSString);
238
239        #[cfg(feature = "NSString")]
240        #[unsafe(method(encodeDouble:forKey:))]
241        #[unsafe(method_family = none)]
242        pub fn encodeDouble_forKey(&self, value: c_double, key: &NSString);
243
244        #[cfg(feature = "NSString")]
245        /// # Safety
246        ///
247        /// `bytes` must be a valid pointer or null.
248        #[unsafe(method(encodeBytes:length:forKey:))]
249        #[unsafe(method_family = none)]
250        pub unsafe fn encodeBytes_length_forKey(
251            &self,
252            bytes: *const u8,
253            length: NSUInteger,
254            key: &NSString,
255        );
256
257        #[unsafe(method(requiresSecureCoding))]
258        #[unsafe(method_family = none)]
259        pub fn requiresSecureCoding(&self) -> bool;
260
261        /// Setter for [`requiresSecureCoding`][Self::requiresSecureCoding].
262        #[unsafe(method(setRequiresSecureCoding:))]
263        #[unsafe(method_family = none)]
264        pub fn setRequiresSecureCoding(&self, requires_secure_coding: bool);
265    );
266}
267
268/// Methods declared on superclass `NSObject`.
269#[cfg(feature = "NSCoder")]
270impl NSKeyedArchiver {
271    extern_methods!(
272        #[unsafe(method(new))]
273        #[unsafe(method_family = new)]
274        pub fn new() -> Retained<Self>;
275    );
276}
277
278#[cfg(feature = "NSCoder")]
279impl DefaultRetained for NSKeyedArchiver {
280    #[inline]
281    fn default_retained() -> Retained<Self> {
282        Self::new()
283    }
284}
285
286extern_class!(
287    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nskeyedunarchiver?language=objc)
288    #[unsafe(super(NSCoder, NSObject))]
289    #[derive(Debug, PartialEq, Eq, Hash)]
290    #[cfg(feature = "NSCoder")]
291    pub struct NSKeyedUnarchiver;
292);
293
294#[cfg(feature = "NSCoder")]
295extern_conformance!(
296    unsafe impl NSObjectProtocol for NSKeyedUnarchiver {}
297);
298
299#[cfg(feature = "NSCoder")]
300impl NSKeyedUnarchiver {
301    extern_methods!(
302        #[cfg(all(feature = "NSData", feature = "NSError"))]
303        /// Initializes the receiver for decoding an archive previously encoded by
304        /// `NSKeyedUnarchiver.`
305        /// Enables
306        /// `requiresSecureCoding`by default. If
307        /// `NSSecureCoding`cannot be used,
308        /// `requiresSecureCoding`may be turned off manually; for improved security,
309        /// `requiresSecureCoding`should be left enabled whenever possible.
310        ///
311        /// Sets the unarchiver's
312        /// `decodingFailurePolicy`to
313        /// `NSDecodingFailurePolicySetErrorAndReturn.`
314        /// Returns
315        /// `nil`if the given data is not valid, and sets the
316        /// `error`out parameter.
317        #[unsafe(method(initForReadingFromData:error:_))]
318        #[unsafe(method_family = init)]
319        pub unsafe fn initForReadingFromData_error(
320            this: Allocated<Self>,
321            data: &NSData,
322        ) -> Result<Retained<Self>, Retained<NSError>>;
323
324        #[cfg(all(feature = "NSData", feature = "NSError"))]
325        /// Decodes the root object of the given class from the given archive, previously encoded by
326        /// `NSKeyedArchiver.`
327        /// Enables
328        /// `requiresSecureCoding`and sets the
329        /// `decodingFailurePolicy`to
330        /// `NSDecodingFailurePolicySetErrorAndReturn.`
331        /// Returns
332        /// `nil`if the given data is not valid or cannot be decoded, and sets the
333        /// `error`out parameter.
334        ///
335        /// # Safety
336        ///
337        /// `cls` probably has further requirements.
338        #[unsafe(method(unarchivedObjectOfClass:fromData:error:_))]
339        #[unsafe(method_family = none)]
340        pub unsafe fn unarchivedObjectOfClass_fromData_error(
341            cls: &AnyClass,
342            data: &NSData,
343        ) -> Result<Retained<AnyObject>, Retained<NSError>>;
344
345        #[cfg(all(feature = "NSArray", feature = "NSData", feature = "NSError"))]
346        /// Decodes the
347        /// `NSArray`root object from
348        /// `data`which should be an
349        /// `NSArray<cls>`containing the given non-collection class (no nested arrays or arrays of dictionaries, etc) from the given archive, previously encoded by
350        /// `NSKeyedArchiver.`Enables
351        /// `requiresSecureCoding`and sets the
352        /// `decodingFailurePolicy`to
353        /// `NSDecodingFailurePolicySetErrorAndReturn.`
354        /// Returns
355        /// `nil`if the given data is not valid or cannot be decoded, and sets the
356        /// `error`out parameter.
357        ///
358        /// # Safety
359        ///
360        /// `cls` probably has further requirements.
361        #[unsafe(method(unarchivedArrayOfObjectsOfClass:fromData:error:_))]
362        #[unsafe(method_family = none)]
363        pub unsafe fn unarchivedArrayOfObjectsOfClass_fromData_error(
364            cls: &AnyClass,
365            data: &NSData,
366        ) -> Result<Retained<NSArray>, Retained<NSError>>;
367
368        #[cfg(all(feature = "NSData", feature = "NSDictionary", feature = "NSError"))]
369        /// Decodes the
370        /// `NSDictionary`root object from
371        /// `data`which should be an
372        /// `NSDictionary<keyCls,objectCls>`with keys of type given in
373        /// `keyCls`and objects of the given non-collection class
374        /// `objectCls`(no nested dictionaries or other dictionaries contained in the dictionary, etc) from the given archive, previously encoded by
375        /// `NSKeyedArchiver.`
376        /// Enables
377        /// `requiresSecureCoding`and sets the
378        /// `decodingFailurePolicy`to
379        /// `NSDecodingFailurePolicySetErrorAndReturn.`
380        /// Returns
381        /// `nil`if the given data is not valid or cannot be decoded, and sets the
382        /// `error`out parameter.
383        ///
384        /// # Safety
385        ///
386        /// - `key_cls` probably has further requirements.
387        /// - `value_cls` probably has further requirements.
388        #[unsafe(method(unarchivedDictionaryWithKeysOfClass:objectsOfClass:fromData:error:_))]
389        #[unsafe(method_family = none)]
390        pub unsafe fn unarchivedDictionaryWithKeysOfClass_objectsOfClass_fromData_error(
391            key_cls: &AnyClass,
392            value_cls: &AnyClass,
393            data: &NSData,
394        ) -> Result<Retained<NSDictionary>, Retained<NSError>>;
395
396        #[cfg(all(feature = "NSData", feature = "NSError", feature = "NSSet"))]
397        /// Decodes the root object of one of the given classes from the given archive, previously encoded by
398        /// `NSKeyedArchiver.`
399        /// Enables
400        /// `requiresSecureCoding`and sets the
401        /// `decodingFailurePolicy`to
402        /// `NSDecodingFailurePolicySetErrorAndReturn.`
403        /// Returns
404        /// `nil`if the given data is not valid or cannot be decoded, and sets the
405        /// `error`out parameter.
406        ///
407        /// # Safety
408        ///
409        /// `classes` generic probably has further requirements.
410        #[unsafe(method(unarchivedObjectOfClasses:fromData:error:_))]
411        #[unsafe(method_family = none)]
412        pub unsafe fn unarchivedObjectOfClasses_fromData_error(
413            classes: &NSSet<AnyClass>,
414            data: &NSData,
415        ) -> Result<Retained<AnyObject>, Retained<NSError>>;
416
417        #[cfg(all(
418            feature = "NSArray",
419            feature = "NSData",
420            feature = "NSError",
421            feature = "NSSet"
422        ))]
423        /// Decodes the
424        /// `NSArray`root object from
425        /// `data`which should be an
426        /// `NSArray,`containing the given non-collection classes in
427        /// `classes`(no nested arrays or arrays of dictionaries, etc) from the given archive, previously encoded by
428        /// `NSKeyedArchiver.`
429        /// Enables
430        /// `requiresSecureCoding`and sets the
431        /// `decodingFailurePolicy`to
432        /// `NSDecodingFailurePolicySetErrorAndReturn.`
433        /// Returns
434        /// `nil`if the given data is not valid or cannot be decoded, and sets the
435        /// `error`out parameter.
436        ///
437        /// # Safety
438        ///
439        /// `classes` generic probably has further requirements.
440        #[unsafe(method(unarchivedArrayOfObjectsOfClasses:fromData:error:_))]
441        #[unsafe(method_family = none)]
442        pub unsafe fn unarchivedArrayOfObjectsOfClasses_fromData_error(
443            classes: &NSSet<AnyClass>,
444            data: &NSData,
445        ) -> Result<Retained<NSArray>, Retained<NSError>>;
446
447        #[cfg(all(
448            feature = "NSData",
449            feature = "NSDictionary",
450            feature = "NSError",
451            feature = "NSSet"
452        ))]
453        /// Decodes the
454        /// `NSDictionary`root object from
455        /// `data`which should be an
456        /// `NSDictionary,`with keys of the types given in
457        /// `keyClasses`and objects of the given non-collection classes in
458        /// `objectClasses`(no nested dictionaries or other dictionaries contained in the dictionary, etc) from the given archive, previously encoded by
459        /// `NSKeyedArchiver.`
460        /// Enables
461        /// `requiresSecureCoding`and sets the
462        /// `decodingFailurePolicy`to
463        /// `NSDecodingFailurePolicySetErrorAndReturn.`
464        /// Returns
465        /// `nil`if the given data is not valid or cannot be decoded, and sets the
466        /// `error`out parameter.
467        ///
468        /// # Safety
469        ///
470        /// - `key_classes` generic probably has further requirements.
471        /// - `value_classes` generic probably has further requirements.
472        #[unsafe(method(unarchivedDictionaryWithKeysOfClasses:objectsOfClasses:fromData:error:_))]
473        #[unsafe(method_family = none)]
474        pub unsafe fn unarchivedDictionaryWithKeysOfClasses_objectsOfClasses_fromData_error(
475            key_classes: &NSSet<AnyClass>,
476            value_classes: &NSSet<AnyClass>,
477            data: &NSData,
478        ) -> Result<Retained<NSDictionary>, Retained<NSError>>;
479
480        #[deprecated = "Use -initForReadingFromData:error: instead"]
481        #[unsafe(method(init))]
482        #[unsafe(method_family = init)]
483        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
484
485        #[cfg(feature = "NSData")]
486        #[deprecated = "Use -initForReadingFromData:error: instead"]
487        #[unsafe(method(initForReadingWithData:))]
488        #[unsafe(method_family = init)]
489        pub unsafe fn initForReadingWithData(
490            this: Allocated<Self>,
491            data: &NSData,
492        ) -> Retained<Self>;
493
494        #[cfg(feature = "NSData")]
495        #[deprecated = "Use +unarchivedObjectOfClass:fromData:error: instead"]
496        #[unsafe(method(unarchiveObjectWithData:))]
497        #[unsafe(method_family = none)]
498        pub unsafe fn unarchiveObjectWithData(data: &NSData) -> Option<Retained<AnyObject>>;
499
500        #[cfg(all(feature = "NSData", feature = "NSError"))]
501        #[deprecated = "Use +unarchivedObjectOfClass:fromData:error: instead"]
502        #[unsafe(method(unarchiveTopLevelObjectWithData:error:_))]
503        #[unsafe(method_family = none)]
504        pub unsafe fn unarchiveTopLevelObjectWithData_error(
505            data: &NSData,
506        ) -> Result<Retained<AnyObject>, Retained<NSError>>;
507
508        #[cfg(feature = "NSString")]
509        #[deprecated = "Use +unarchivedObjectOfClass:fromData:error: instead"]
510        #[unsafe(method(unarchiveObjectWithFile:))]
511        #[unsafe(method_family = none)]
512        pub unsafe fn unarchiveObjectWithFile(path: &NSString) -> Option<Retained<AnyObject>>;
513
514        /// # Safety
515        ///
516        /// This is not retained internally, you must ensure the object is still alive.
517        #[unsafe(method(delegate))]
518        #[unsafe(method_family = none)]
519        pub unsafe fn delegate(
520            &self,
521        ) -> Option<Retained<ProtocolObject<dyn NSKeyedUnarchiverDelegate>>>;
522
523        /// Setter for [`delegate`][Self::delegate].
524        ///
525        /// # Safety
526        ///
527        /// This is unretained, you must ensure the object is kept alive while in use.
528        #[unsafe(method(setDelegate:))]
529        #[unsafe(method_family = none)]
530        pub unsafe fn setDelegate(
531            &self,
532            delegate: Option<&ProtocolObject<dyn NSKeyedUnarchiverDelegate>>,
533        );
534
535        #[unsafe(method(finishDecoding))]
536        #[unsafe(method_family = none)]
537        pub unsafe fn finishDecoding(&self);
538
539        #[cfg(feature = "NSString")]
540        /// # Safety
541        ///
542        /// `cls` probably has further requirements.
543        #[unsafe(method(setClass:forClassName:))]
544        #[unsafe(method_family = none)]
545        pub unsafe fn setClass_forClassName_class(cls: Option<&AnyClass>, coded_name: &NSString);
546
547        #[cfg(feature = "NSString")]
548        /// # Safety
549        ///
550        /// `cls` probably has further requirements.
551        #[unsafe(method(setClass:forClassName:))]
552        #[unsafe(method_family = none)]
553        pub unsafe fn setClass_forClassName(&self, cls: Option<&AnyClass>, coded_name: &NSString);
554
555        #[cfg(feature = "NSString")]
556        #[unsafe(method(classForClassName:))]
557        #[unsafe(method_family = none)]
558        pub unsafe fn classForClassName_class(coded_name: &NSString) -> Option<&'static AnyClass>;
559
560        #[cfg(feature = "NSString")]
561        #[unsafe(method(classForClassName:))]
562        #[unsafe(method_family = none)]
563        pub unsafe fn classForClassName(&self, coded_name: &NSString) -> Option<&'static AnyClass>;
564
565        #[cfg(feature = "NSString")]
566        #[unsafe(method(containsValueForKey:))]
567        #[unsafe(method_family = none)]
568        pub unsafe fn containsValueForKey(&self, key: &NSString) -> bool;
569
570        #[cfg(feature = "NSString")]
571        #[unsafe(method(decodeObjectForKey:))]
572        #[unsafe(method_family = none)]
573        pub unsafe fn decodeObjectForKey(&self, key: &NSString) -> Option<Retained<AnyObject>>;
574
575        #[cfg(feature = "NSString")]
576        #[unsafe(method(decodeBoolForKey:))]
577        #[unsafe(method_family = none)]
578        pub unsafe fn decodeBoolForKey(&self, key: &NSString) -> bool;
579
580        #[cfg(feature = "NSString")]
581        #[unsafe(method(decodeIntForKey:))]
582        #[unsafe(method_family = none)]
583        pub unsafe fn decodeIntForKey(&self, key: &NSString) -> c_int;
584
585        #[cfg(feature = "NSString")]
586        #[unsafe(method(decodeInt32ForKey:))]
587        #[unsafe(method_family = none)]
588        pub unsafe fn decodeInt32ForKey(&self, key: &NSString) -> i32;
589
590        #[cfg(feature = "NSString")]
591        #[unsafe(method(decodeInt64ForKey:))]
592        #[unsafe(method_family = none)]
593        pub unsafe fn decodeInt64ForKey(&self, key: &NSString) -> i64;
594
595        #[cfg(feature = "NSString")]
596        #[unsafe(method(decodeFloatForKey:))]
597        #[unsafe(method_family = none)]
598        pub unsafe fn decodeFloatForKey(&self, key: &NSString) -> c_float;
599
600        #[cfg(feature = "NSString")]
601        #[unsafe(method(decodeDoubleForKey:))]
602        #[unsafe(method_family = none)]
603        pub unsafe fn decodeDoubleForKey(&self, key: &NSString) -> c_double;
604
605        #[cfg(feature = "NSString")]
606        /// # Safety
607        ///
608        /// `lengthp` must be a valid pointer or null.
609        #[unsafe(method(decodeBytesForKey:returnedLength:))]
610        #[unsafe(method_family = none)]
611        pub unsafe fn decodeBytesForKey_returnedLength(
612            &self,
613            key: &NSString,
614            lengthp: *mut NSUInteger,
615        ) -> *const u8;
616
617        #[unsafe(method(requiresSecureCoding))]
618        #[unsafe(method_family = none)]
619        pub unsafe fn requiresSecureCoding(&self) -> bool;
620
621        /// Setter for [`requiresSecureCoding`][Self::requiresSecureCoding].
622        #[unsafe(method(setRequiresSecureCoding:))]
623        #[unsafe(method_family = none)]
624        pub unsafe fn setRequiresSecureCoding(&self, requires_secure_coding: bool);
625
626        #[unsafe(method(decodingFailurePolicy))]
627        #[unsafe(method_family = none)]
628        pub unsafe fn decodingFailurePolicy(&self) -> NSDecodingFailurePolicy;
629
630        /// Setter for [`decodingFailurePolicy`][Self::decodingFailurePolicy].
631        #[unsafe(method(setDecodingFailurePolicy:))]
632        #[unsafe(method_family = none)]
633        pub unsafe fn setDecodingFailurePolicy(
634            &self,
635            decoding_failure_policy: NSDecodingFailurePolicy,
636        );
637    );
638}
639
640/// Methods declared on superclass `NSObject`.
641#[cfg(feature = "NSCoder")]
642impl NSKeyedUnarchiver {
643    extern_methods!(
644        #[unsafe(method(new))]
645        #[unsafe(method_family = new)]
646        pub unsafe fn new() -> Retained<Self>;
647    );
648}
649
650extern_protocol!(
651    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nskeyedarchiverdelegate?language=objc)
652    pub unsafe trait NSKeyedArchiverDelegate: NSObjectProtocol {
653        #[cfg(feature = "NSCoder")]
654        /// # Safety
655        ///
656        /// `object` should be of the correct type.
657        #[optional]
658        #[unsafe(method(archiver:willEncodeObject:))]
659        #[unsafe(method_family = none)]
660        unsafe fn archiver_willEncodeObject(
661            &self,
662            archiver: &NSKeyedArchiver,
663            object: &AnyObject,
664        ) -> Option<Retained<AnyObject>>;
665
666        #[cfg(feature = "NSCoder")]
667        /// # Safety
668        ///
669        /// `object` should be of the correct type.
670        #[optional]
671        #[unsafe(method(archiver:didEncodeObject:))]
672        #[unsafe(method_family = none)]
673        unsafe fn archiver_didEncodeObject(
674            &self,
675            archiver: &NSKeyedArchiver,
676            object: Option<&AnyObject>,
677        );
678
679        #[cfg(feature = "NSCoder")]
680        /// # Safety
681        ///
682        /// - `object` should be of the correct type.
683        /// - `new_object` should be of the correct type.
684        #[optional]
685        #[unsafe(method(archiver:willReplaceObject:withObject:))]
686        #[unsafe(method_family = none)]
687        unsafe fn archiver_willReplaceObject_withObject(
688            &self,
689            archiver: &NSKeyedArchiver,
690            object: Option<&AnyObject>,
691            new_object: Option<&AnyObject>,
692        );
693
694        #[cfg(feature = "NSCoder")]
695        #[optional]
696        #[unsafe(method(archiverWillFinish:))]
697        #[unsafe(method_family = none)]
698        fn archiverWillFinish(&self, archiver: &NSKeyedArchiver);
699
700        #[cfg(feature = "NSCoder")]
701        #[optional]
702        #[unsafe(method(archiverDidFinish:))]
703        #[unsafe(method_family = none)]
704        fn archiverDidFinish(&self, archiver: &NSKeyedArchiver);
705    }
706);
707
708extern_protocol!(
709    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nskeyedunarchiverdelegate?language=objc)
710    pub unsafe trait NSKeyedUnarchiverDelegate: NSObjectProtocol {
711        #[cfg(all(feature = "NSArray", feature = "NSCoder", feature = "NSString"))]
712        #[optional]
713        #[unsafe(method(unarchiver:cannotDecodeObjectOfClassName:originalClasses:))]
714        #[unsafe(method_family = none)]
715        fn unarchiver_cannotDecodeObjectOfClassName_originalClasses(
716            &self,
717            unarchiver: &NSKeyedUnarchiver,
718            name: &NSString,
719            class_names: &NSArray<NSString>,
720        ) -> Option<&'static AnyClass>;
721
722        #[cfg(feature = "NSCoder")]
723        /// # Safety
724        ///
725        /// - `object` should be of the correct type.
726        /// - `new_object` should be of the correct type.
727        #[optional]
728        #[unsafe(method(unarchiver:willReplaceObject:withObject:))]
729        #[unsafe(method_family = none)]
730        unsafe fn unarchiver_willReplaceObject_withObject(
731            &self,
732            unarchiver: &NSKeyedUnarchiver,
733            object: &AnyObject,
734            new_object: &AnyObject,
735        );
736
737        #[cfg(feature = "NSCoder")]
738        #[optional]
739        #[unsafe(method(unarchiverWillFinish:))]
740        #[unsafe(method_family = none)]
741        fn unarchiverWillFinish(&self, unarchiver: &NSKeyedUnarchiver);
742
743        #[cfg(feature = "NSCoder")]
744        #[optional]
745        #[unsafe(method(unarchiverDidFinish:))]
746        #[unsafe(method_family = none)]
747        fn unarchiverDidFinish(&self, unarchiver: &NSKeyedUnarchiver);
748    }
749);
750
751mod private_NSObjectNSKeyedArchiverObjectSubstitution {
752    pub trait Sealed {}
753}
754
755/// Category "NSKeyedArchiverObjectSubstitution" on [`NSObject`].
756#[doc(alias = "NSKeyedArchiverObjectSubstitution")]
757pub unsafe trait NSObjectNSKeyedArchiverObjectSubstitution:
758    ClassType + Sized + private_NSObjectNSKeyedArchiverObjectSubstitution::Sealed
759{
760    extern_methods!(
761        #[unsafe(method(classForKeyedArchiver))]
762        #[unsafe(method_family = none)]
763        fn classForKeyedArchiver(&self) -> Option<&'static AnyClass>;
764
765        #[cfg(feature = "NSCoder")]
766        #[unsafe(method(replacementObjectForKeyedArchiver:))]
767        #[unsafe(method_family = none)]
768        fn replacementObjectForKeyedArchiver(
769            &self,
770            archiver: &NSKeyedArchiver,
771        ) -> Option<Retained<AnyObject>>;
772
773        #[cfg(all(feature = "NSArray", feature = "NSString"))]
774        #[unsafe(method(classFallbacksForKeyedArchiver))]
775        #[unsafe(method_family = none)]
776        fn classFallbacksForKeyedArchiver() -> Retained<NSArray<NSString>>;
777    );
778}
779
780impl private_NSObjectNSKeyedArchiverObjectSubstitution::Sealed for NSObject {}
781unsafe impl NSObjectNSKeyedArchiverObjectSubstitution for NSObject {}
782
783mod private_NSObjectNSKeyedUnarchiverObjectSubstitution {
784    pub trait Sealed {}
785}
786
787/// Category "NSKeyedUnarchiverObjectSubstitution" on [`NSObject`].
788#[doc(alias = "NSKeyedUnarchiverObjectSubstitution")]
789pub unsafe trait NSObjectNSKeyedUnarchiverObjectSubstitution:
790    ClassType + Sized + private_NSObjectNSKeyedUnarchiverObjectSubstitution::Sealed
791{
792    extern_methods!(
793        #[unsafe(method(classForKeyedUnarchiver))]
794        #[unsafe(method_family = none)]
795        fn classForKeyedUnarchiver() -> &'static AnyClass;
796    );
797}
798
799impl private_NSObjectNSKeyedUnarchiverObjectSubstitution::Sealed for NSObject {}
800unsafe impl NSObjectNSKeyedUnarchiverObjectSubstitution for NSObject {}