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")]
131unsafe impl NSCoding for NSError {}
132
133#[cfg(feature = "NSObject")]
134unsafe impl NSCopying for NSError {}
135
136#[cfg(feature = "NSObject")]
137unsafe impl CopyingHelper for NSError {
138 type Result = Self;
139}
140
141unsafe impl NSObjectProtocol for NSError {}
142
143#[cfg(feature = "NSObject")]
144unsafe impl NSSecureCoding for NSError {}
145
146impl NSError {
147 extern_methods!(
148 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
149 #[unsafe(method(initWithDomain:code:userInfo:))]
150 #[unsafe(method_family = init)]
151 pub unsafe fn initWithDomain_code_userInfo(
152 this: Allocated<Self>,
153 domain: &NSErrorDomain,
154 code: NSInteger,
155 dict: Option<&NSDictionary<NSErrorUserInfoKey, AnyObject>>,
156 ) -> Retained<Self>;
157
158 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
159 #[unsafe(method(errorWithDomain:code:userInfo:))]
160 #[unsafe(method_family = none)]
161 pub unsafe fn errorWithDomain_code_userInfo(
162 domain: &NSErrorDomain,
163 code: NSInteger,
164 dict: Option<&NSDictionary<NSErrorUserInfoKey, AnyObject>>,
165 ) -> Retained<Self>;
166
167 #[cfg(feature = "NSString")]
168 #[unsafe(method(domain))]
169 #[unsafe(method_family = none)]
170 pub fn domain(&self) -> Retained<NSErrorDomain>;
171
172 #[unsafe(method(code))]
173 #[unsafe(method_family = none)]
174 pub fn code(&self) -> NSInteger;
175
176 #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
177 #[unsafe(method(userInfo))]
178 #[unsafe(method_family = none)]
179 pub fn userInfo(&self) -> Retained<NSDictionary<NSErrorUserInfoKey, AnyObject>>;
180
181 #[cfg(feature = "NSString")]
182 #[unsafe(method(localizedDescription))]
183 #[unsafe(method_family = none)]
184 pub fn localizedDescription(&self) -> Retained<NSString>;
185
186 #[cfg(feature = "NSString")]
187 #[unsafe(method(localizedFailureReason))]
188 #[unsafe(method_family = none)]
189 pub unsafe fn localizedFailureReason(&self) -> Option<Retained<NSString>>;
190
191 #[cfg(feature = "NSString")]
192 #[unsafe(method(localizedRecoverySuggestion))]
193 #[unsafe(method_family = none)]
194 pub unsafe fn localizedRecoverySuggestion(&self) -> Option<Retained<NSString>>;
195
196 #[cfg(all(feature = "NSArray", feature = "NSString"))]
197 #[unsafe(method(localizedRecoveryOptions))]
198 #[unsafe(method_family = none)]
199 pub unsafe fn localizedRecoveryOptions(&self) -> Option<Retained<NSArray<NSString>>>;
200
201 #[unsafe(method(recoveryAttempter))]
202 #[unsafe(method_family = none)]
203 pub unsafe fn recoveryAttempter(&self) -> Option<Retained<AnyObject>>;
204
205 #[cfg(feature = "NSString")]
206 #[unsafe(method(helpAnchor))]
207 #[unsafe(method_family = none)]
208 pub unsafe fn helpAnchor(&self) -> Option<Retained<NSString>>;
209
210 #[cfg(feature = "NSArray")]
211 #[unsafe(method(underlyingErrors))]
212 #[unsafe(method_family = none)]
213 pub unsafe fn underlyingErrors(&self) -> Retained<NSArray<NSError>>;
214
215 #[cfg(all(feature = "NSString", feature = "block2"))]
216 #[unsafe(method(setUserInfoValueProviderForDomain:provider:))]
217 #[unsafe(method_family = none)]
218 pub unsafe fn setUserInfoValueProviderForDomain_provider(
219 error_domain: &NSErrorDomain,
220 provider: Option<
221 &block2::Block<
222 dyn Fn(NonNull<NSError>, NonNull<NSErrorUserInfoKey>) -> *mut AnyObject,
223 >,
224 >,
225 );
226
227 #[cfg(all(feature = "NSString", feature = "block2"))]
228 #[unsafe(method(userInfoValueProviderForDomain:))]
229 #[unsafe(method_family = none)]
230 pub unsafe fn userInfoValueProviderForDomain(
231 error_domain: &NSErrorDomain,
232 ) -> *mut block2::Block<
233 dyn Fn(NonNull<NSError>, NonNull<NSErrorUserInfoKey>) -> *mut AnyObject,
234 >;
235 );
236}
237
238impl NSError {
240 extern_methods!(
241 #[unsafe(method(init))]
242 #[unsafe(method_family = init)]
243 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
244 );
245}
246
247mod private_NSObjectNSErrorRecoveryAttempting {
248 pub trait Sealed {}
249}
250
251#[doc(alias = "NSErrorRecoveryAttempting")]
253pub unsafe trait NSObjectNSErrorRecoveryAttempting:
254 ClassType + Sized + private_NSObjectNSErrorRecoveryAttempting::Sealed
255{
256 extern_methods!(
257 #[unsafe(method(attemptRecoveryFromError:optionIndex:delegate:didRecoverSelector:contextInfo:))]
258 #[unsafe(method_family = none)]
259 unsafe fn attemptRecoveryFromError_optionIndex_delegate_didRecoverSelector_contextInfo(
260 &self,
261 error: &NSError,
262 recovery_option_index: NSUInteger,
263 delegate: Option<&AnyObject>,
264 did_recover_selector: Option<Sel>,
265 context_info: *mut c_void,
266 );
267
268 #[unsafe(method(attemptRecoveryFromError:optionIndex:))]
269 #[unsafe(method_family = none)]
270 unsafe fn attemptRecoveryFromError_optionIndex(
271 &self,
272 error: &NSError,
273 recovery_option_index: NSUInteger,
274 ) -> bool;
275 );
276}
277
278impl private_NSObjectNSErrorRecoveryAttempting::Sealed for NSObject {}
279unsafe impl NSObjectNSErrorRecoveryAttempting for NSObject {}