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