objc2_foundation/generated/
NSError.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8
9use crate::*;
10
11#[cfg(feature = "NSString")]
13pub type NSErrorDomain = NSString;
14
15extern "C" {
16 #[cfg(feature = "NSString")]
18 pub static NSCocoaErrorDomain: &'static NSErrorDomain;
19}
20
21extern "C" {
22 #[cfg(feature = "NSString")]
24 pub static NSPOSIXErrorDomain: &'static NSErrorDomain;
25}
26
27extern "C" {
28 #[cfg(feature = "NSString")]
30 pub static NSOSStatusErrorDomain: &'static NSErrorDomain;
31}
32
33extern "C" {
34 #[cfg(feature = "NSString")]
36 pub static NSMachErrorDomain: &'static NSErrorDomain;
37}
38
39#[cfg(feature = "NSString")]
41pub type NSErrorUserInfoKey = NSString;
42
43extern "C" {
44 #[cfg(feature = "NSString")]
46 pub static NSUnderlyingErrorKey: &'static NSErrorUserInfoKey;
47}
48
49extern "C" {
50 #[cfg(feature = "NSString")]
52 pub static NSMultipleUnderlyingErrorsKey: &'static NSErrorUserInfoKey;
53}
54
55extern "C" {
56 #[cfg(feature = "NSString")]
58 pub static NSLocalizedDescriptionKey: &'static NSErrorUserInfoKey;
59}
60
61extern "C" {
62 #[cfg(feature = "NSString")]
64 pub static NSLocalizedFailureReasonErrorKey: &'static NSErrorUserInfoKey;
65}
66
67extern "C" {
68 #[cfg(feature = "NSString")]
70 pub static NSLocalizedRecoverySuggestionErrorKey: &'static NSErrorUserInfoKey;
71}
72
73extern "C" {
74 #[cfg(feature = "NSString")]
76 pub static NSLocalizedRecoveryOptionsErrorKey: &'static NSErrorUserInfoKey;
77}
78
79extern "C" {
80 #[cfg(feature = "NSString")]
82 pub static NSRecoveryAttempterErrorKey: &'static NSErrorUserInfoKey;
83}
84
85extern "C" {
86 #[cfg(feature = "NSString")]
88 pub static NSHelpAnchorErrorKey: &'static NSErrorUserInfoKey;
89}
90
91extern "C" {
92 #[cfg(feature = "NSString")]
94 pub static NSDebugDescriptionErrorKey: &'static NSErrorUserInfoKey;
95}
96
97extern "C" {
98 #[cfg(feature = "NSString")]
100 pub static NSLocalizedFailureErrorKey: &'static NSErrorUserInfoKey;
101}
102
103extern "C" {
104 #[cfg(feature = "NSString")]
106 pub static NSStringEncodingErrorKey: &'static NSErrorUserInfoKey;
107}
108
109extern "C" {
110 #[cfg(feature = "NSString")]
112 pub static NSURLErrorKey: &'static NSErrorUserInfoKey;
113}
114
115extern "C" {
116 #[cfg(feature = "NSString")]
118 pub static NSFilePathErrorKey: &'static NSErrorUserInfoKey;
119}
120
121extern_class!(
122 #[unsafe(super(NSObject))]
124 #[derive(PartialEq, Eq, Hash)]
125 pub struct NSError;
126);
127
128unsafe impl Send for NSError {}
129
130unsafe impl Sync for NSError {}
131
132#[cfg(feature = "objc2-core-foundation")]
133impl AsRef<NSError> for CFError {
134 #[inline]
135 fn as_ref(&self) -> &NSError {
136 unsafe { &*((self as *const Self).cast()) }
137 }
138}
139
140#[cfg(feature = "objc2-core-foundation")]
141impl AsRef<CFError> for NSError {
142 #[inline]
143 fn as_ref(&self) -> &CFError {
144 unsafe { &*((self as *const Self).cast()) }
145 }
146}
147
148#[cfg(feature = "NSObject")]
149extern_conformance!(
150 unsafe impl NSCoding for NSError {}
151);
152
153#[cfg(feature = "NSObject")]
154extern_conformance!(
155 unsafe impl NSCopying for NSError {}
156);
157
158#[cfg(feature = "NSObject")]
159unsafe impl CopyingHelper for NSError {
160 type Result = Self;
161}
162
163extern_conformance!(
164 unsafe impl NSObjectProtocol for NSError {}
165);
166
167#[cfg(feature = "NSObject")]
168extern_conformance!(
169 unsafe impl NSSecureCoding for NSError {}
170);
171
172impl NSError {
173 extern_methods!(
174 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
175 #[unsafe(method(initWithDomain:code:userInfo:))]
179 #[unsafe(method_family = init)]
180 pub unsafe fn initWithDomain_code_userInfo(
181 this: Allocated<Self>,
182 domain: &NSErrorDomain,
183 code: NSInteger,
184 dict: Option<&NSDictionary<NSErrorUserInfoKey, AnyObject>>,
185 ) -> Retained<Self>;
186
187 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
188 #[unsafe(method(errorWithDomain:code:userInfo:))]
192 #[unsafe(method_family = none)]
193 pub unsafe fn errorWithDomain_code_userInfo(
194 domain: &NSErrorDomain,
195 code: NSInteger,
196 dict: Option<&NSDictionary<NSErrorUserInfoKey, AnyObject>>,
197 ) -> Retained<Self>;
198
199 #[cfg(feature = "NSString")]
200 #[unsafe(method(domain))]
201 #[unsafe(method_family = none)]
202 pub fn domain(&self) -> Retained<NSErrorDomain>;
203
204 #[unsafe(method(code))]
205 #[unsafe(method_family = none)]
206 pub fn code(&self) -> NSInteger;
207
208 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
209 #[unsafe(method(userInfo))]
210 #[unsafe(method_family = none)]
211 pub fn userInfo(&self) -> Retained<NSDictionary<NSErrorUserInfoKey, AnyObject>>;
212
213 #[cfg(feature = "NSString")]
214 #[unsafe(method(localizedDescription))]
215 #[unsafe(method_family = none)]
216 pub fn localizedDescription(&self) -> Retained<NSString>;
217
218 #[cfg(feature = "NSString")]
219 #[unsafe(method(localizedFailureReason))]
220 #[unsafe(method_family = none)]
221 pub fn localizedFailureReason(&self) -> Option<Retained<NSString>>;
222
223 #[cfg(feature = "NSString")]
224 #[unsafe(method(localizedRecoverySuggestion))]
225 #[unsafe(method_family = none)]
226 pub fn localizedRecoverySuggestion(&self) -> Option<Retained<NSString>>;
227
228 #[cfg(all(feature = "NSArray", feature = "NSString"))]
229 #[unsafe(method(localizedRecoveryOptions))]
230 #[unsafe(method_family = none)]
231 pub fn localizedRecoveryOptions(&self) -> Option<Retained<NSArray<NSString>>>;
232
233 #[unsafe(method(recoveryAttempter))]
234 #[unsafe(method_family = none)]
235 pub fn recoveryAttempter(&self) -> Option<Retained<AnyObject>>;
236
237 #[cfg(feature = "NSString")]
238 #[unsafe(method(helpAnchor))]
239 #[unsafe(method_family = none)]
240 pub fn helpAnchor(&self) -> Option<Retained<NSString>>;
241
242 #[cfg(feature = "NSArray")]
243 #[unsafe(method(underlyingErrors))]
244 #[unsafe(method_family = none)]
245 pub fn underlyingErrors(&self) -> Retained<NSArray<NSError>>;
246
247 #[cfg(all(feature = "NSString", feature = "block2"))]
248 #[unsafe(method(setUserInfoValueProviderForDomain:provider:))]
252 #[unsafe(method_family = none)]
253 pub unsafe fn setUserInfoValueProviderForDomain_provider(
254 error_domain: &NSErrorDomain,
255 provider: Option<
256 &block2::DynBlock<
257 dyn Fn(NonNull<NSError>, NonNull<NSErrorUserInfoKey>) -> *mut AnyObject,
258 >,
259 >,
260 );
261
262 #[cfg(all(feature = "NSString", feature = "block2"))]
263 #[unsafe(method(userInfoValueProviderForDomain:))]
267 #[unsafe(method_family = none)]
268 pub unsafe fn userInfoValueProviderForDomain(
269 error_domain: &NSErrorDomain,
270 ) -> *mut block2::DynBlock<
271 dyn Fn(NonNull<NSError>, NonNull<NSErrorUserInfoKey>) -> *mut AnyObject,
272 >;
273 );
274}
275
276impl NSError {
278 extern_methods!(
279 #[unsafe(method(init))]
280 #[unsafe(method_family = init)]
281 pub fn init(this: Allocated<Self>) -> Retained<Self>;
282 );
283}
284
285mod private_NSObjectNSErrorRecoveryAttempting {
286 pub trait Sealed {}
287}
288
289#[doc(alias = "NSErrorRecoveryAttempting")]
291pub unsafe trait NSObjectNSErrorRecoveryAttempting:
292 ClassType + Sized + private_NSObjectNSErrorRecoveryAttempting::Sealed
293{
294 extern_methods!(
295 #[unsafe(method(attemptRecoveryFromError:optionIndex:delegate:didRecoverSelector:contextInfo:))]
301 #[unsafe(method_family = none)]
302 unsafe fn attemptRecoveryFromError_optionIndex_delegate_didRecoverSelector_contextInfo(
303 &self,
304 error: &NSError,
305 recovery_option_index: NSUInteger,
306 delegate: Option<&AnyObject>,
307 did_recover_selector: Option<Sel>,
308 context_info: *mut c_void,
309 );
310
311 #[unsafe(method(attemptRecoveryFromError:optionIndex:))]
312 #[unsafe(method_family = none)]
313 fn attemptRecoveryFromError_optionIndex(
314 &self,
315 error: &NSError,
316 recovery_option_index: NSUInteger,
317 ) -> bool;
318 );
319}
320
321impl private_NSObjectNSErrorRecoveryAttempting::Sealed for NSObject {}
322unsafe impl NSObjectNSErrorRecoveryAttempting for NSObject {}