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