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