fruity__bbqsrc 0.2.0

Rusty bindings for Apple libraries
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
ns_string_wrapper! {
    /// The name of an [`NSException`](struct.NSException.html).
    ///
    /// See [documentation](https://developer.apple.com/documentation/foundation/nsexceptionname).
    #[derive(Ord, PartialOrd, Eq, PartialEq)]
    pub wrapper NSExceptionName;
}

macro_rules! name {
    (
        $(#[$docs:meta])+
        $fn:ident $value:literal
    ) => {
        $(#[$docs])+
        #[inline]
        #[doc(alias = $value)]
        pub fn $fn() -> &'static NSExceptionName {
            extern "C" {
                #[link_name = $value]
                static VALUE: &'static NSExceptionName;
            }
            unsafe { VALUE }
        }
    };
}

/// Uncategorized exceptions.
impl NSExceptionName {
    name! {
        /// A generic name for an exception.
        ///
        /// You should typically use a more specific exception name.
        ///
        /// See [documentation](https://developer.apple.com/documentation/foundation/nsgenericexception).
        generic "NSGenericException"
    }

    name! {
        /// The exception raised when an internal assertion fails and implies an
        /// unexpected condition within the called code.
        ///
        /// See [documentation](https://developer.apple.com/documentation/foundation/nsinternalinconsistencyexception).
        internal_inconsistency "NSInternalInconsistencyException"
    }

    name! {
        /// The exception raised when you pass an invalid argument to a method,
        /// such as a `nil` (null/`None`) pointer where a non-`nil` object is
        /// required.
        ///
        /// See [documentation](https://developer.apple.com/documentation/foundation/nsinvalidargumentexception).
        invalid_argument "NSInvalidArgumentException"
    }
}

/// [`NSString`](struct.NSString.html) exceptions.
impl NSExceptionName {
    name! {
        /// The exception raised when a string cannot be represented in a
        /// file-system or string encoding.
        ///
        /// See [documentation](https://developer.apple.com/documentation/foundation/nscharacterconversionexception).
        character_conversion "NSCharacterConversionException"
    }

    name! {
        /// The exception raised when a string cannot be parsed as a property
        /// list.
        ///
        /// See [documentation](https://developer.apple.com/documentation/foundation/nsparseerrorexception).
        parse_error "NSParseErrorException"
    }
}

/// [`NSDecimalNumber`](struct.NSDecimalNumber.html) exceptions.
impl NSExceptionName {
    name! {
        /// The exception raised if there is an exactness error.
        ///
        /// See [documentation](https://developer.apple.com/documentation/foundation/nsdecimalnumberexactnessexception).
        decimal_number_exactness "NSDecimalNumberExactnessException"
    }

    name! {
        /// The exception raised on overflow.
        ///
        /// See [documentation](https://developer.apple.com/documentation/foundation/nsdecimalnumberoverflowexception).
        decimal_number_overflow "NSDecimalNumberOverflowException"
    }

    name! {
        /// The exception raised on underflow.
        ///
        /// See [documentation](https://developer.apple.com/documentation/foundation/nsdecimalnumberunderflowexception).
        decimal_number_underflow "NSDecimalNumberUnderflowException"
    }

    name! {
        /// The exception raised on divide by zero.
        ///
        /// See [documentation](https://developer.apple.com/documentation/foundation/nsdecimalnumberdividebyzeroexception).
        decimal_number_divide_by_zero "NSDecimalNumberDivideByZeroException"
    }
}

/// [`NSFileHandle`](struct.NSFileHandle.html) exceptions.
///
/// See [documentation](https://developer.apple.com/documentation/foundation/nsfilehandle/exception_names).
impl NSExceptionName {
    name! {
        /// The exception raised if attempts to determine file-handle type fail
        /// or if attempts to read from a file or channel fail.
        ///
        /// See [documentation](https://developer.apple.com/documentation/foundation/nsfilehandleoperationexception).
        file_handle_operation "NSFileHandleOperationException"
    }
}

/// [`NSInvocation`](struct.NSInvocation.html) exceptions.
impl NSExceptionName {
    name! {
        /// The exception raised if the `result` method is called after the
        /// operation was cancelled.
        ///
        /// See [documentation](https://developer.apple.com/documentation/foundation/nsinvalidarchiveoperationexception).
        invocation_operation_cancelled "NSInvocationOperationCancelledException"
    }

    name! {
        /// The exception raised if the `result` method is called for an
        /// invocation method with a `void` return type.
        ///
        /// See [documentation](https://developer.apple.com/documentation/foundation/nsinvocationoperationvoidresultexception).
        invocation_operation_void_result "NSInvocationOperationVoidResultException"
    }
}

/// [`NSArchiver`](struct.NSArchiver.html) exceptions.
impl NSExceptionName {
    name! {
        /// The exception raised if there are problems initializing or encoding.
        ///
        /// See [documentation](https://developer.apple.com/documentation/foundation/nsinvalidarchiveoperationexception).
        inconsistent_archive "NSInconsistentArchiveException"
    }
}

/// [`NSKeyedArchiver`](struct.NSKeyedArchiver.html) exceptions.
///
/// See [documentation](https://developer.apple.com/documentation/foundation/nskeyedarchiver/keyed_archiving_exception_names).
impl NSExceptionName {
    name! {
        /// The exception raised if there is a problem creating an archive.
        ///
        /// See [documentation](https://developer.apple.com/documentation/foundation/nsinvalidarchiveoperationexception).
        invalid_archive_operation "NSInvalidArchiveOperationException"
    }

    name! {
        /// The exception raised if there is a problem extracting an archive.
        ///
        /// See [documentation](https://developer.apple.com/documentation/foundation/nsinvalidunarchiveoperationexception).
        invalid_unarchive_operation "NSInvalidUnarchiveOperationException"
    }
}

/// [`NSPort`](struct.NSPort.html) exceptions.
impl NSExceptionName {
    name! {
        /// The exception raised when a generic error occurred on receive.
        ///
        /// See [documentation](https://developer.apple.com/documentation/foundation/nsportreceiveexception).
        port_receive "NSPortReceiveException"
    }

    name! {
        /// The exception raised when a generic error occurred on send.
        ///
        /// See [documentation](https://developer.apple.com/documentation/foundation/nsportsendexception).
        port_send "NSPortSendException"
    }

    name! {
        /// The exception raised when a timeout set on a port expires during a
        /// send or receive operation.
        ///
        /// See [documentation](https://developer.apple.com/documentation/foundation/nsporttimeoutexception).
        port_timeout "NSPortTimeoutException"
    }
}

/// [`NSRange`](struct.NSRange.html) exceptions.
impl NSExceptionName {
    name! {
        /// The exception raised when attempting to access outside the bounds of
        /// some data, such as beyond the end of a string.
        ///
        /// See [documentation](https://developer.apple.com/documentation/foundation/nsrangeexception).
        range "NSRangeException"
    }
}

/// Key value coding exceptions.
impl NSExceptionName {
    name! {
        /// The exception raised when a key value coding operation fails.
        ///
        /// `userInfo` keys are described in
        /// [NSUndefinedKeyException userInfo Keys](https://developer.apple.com/documentation/foundation/nsundefinedkeyexception).
        ///
        /// See [documentation](https://developer.apple.com/documentation/foundation/nsundefinedkeyexception).
        undefined_key "NSUndefinedKeyException"
    }
}

/// Distributed object exceptions.
impl NSExceptionName {
    name! {
        /// The exception that occurs when an internal assertion fails and
        /// implies an unexpected condition within the distributed objects.
        ///
        /// See [documentation](https://developer.apple.com/documentation/foundation/nsdestinationinvalidexception).
        destination_invalid "NSDestinationInvalidException"
    }

    name! {
        /// The exception raised when the receive port of an
        /// [`NSConnection`](struct.NSConnection.html) has become invalid.
        ///
        /// See [documentation](https://developer.apple.com/documentation/foundation/nsinvalidreceiveportexception).
        invalid_receive_port "NSInvalidReceivePortException"
    }

    name! {
        /// The exception raised when the send port of an
        /// [`NSConnection`](struct.NSConnection.html) has become invalid.
        ///
        /// See [documentation](https://developer.apple.com/documentation/foundation/nsinvalidsendportexception).
        invalid_send_port "NSInvalidSendPortException"
    }

    name! {
        /// The exception raised when a remote object is accessed from a thread
        /// that should not access it.
        ///
        /// See [documentation](https://developer.apple.com/documentation/foundation/nsinvalidsendportexception).
        object_inaccessible "NSObjectInaccessibleException"
    }

    name! {
        /// The exception raised when the remote side of the
        /// [`NSConnection`](struct.NSConnection.html) refused to send the
        /// message to the object because the object has never been vended.
        ///
        /// See [documentation](https://developer.apple.com/documentation/foundation/nsobjectnotavailableexception).
        object_not_available "NSObjectNotAvailableException"
    }
}

// Defined after everything else in order to appear at the end of documentation.

/// AppKit exceptions.
///
/// Requires the **`app_kit`** feature flag.
#[cfg(feature = "app_kit")]
impl NSExceptionName {
    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nstextlinetoolongexception).
        text_line_too_long "NSTextLineTooLongException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nstextnoselectionexception).
        text_no_selection "NSTextNoSelectionException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nswordtableswriteexception).
        word_tables_write "NSWordTablesWriteException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nswordtablesreadexception).
        word_tables_read "NSWordTablesReadException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nstextreadexception).
        text_read "NSTextReadException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nstextwriteexception).
        text_write "NSTextWriteException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nspasteboardcommunicationexception).
        pasteboard_communication "NSPasteboardCommunicationException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nsprintingcommunicationexception).
        printing_communication "NSPrintingCommunicationException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nsabortmodalexception).
        abort_modal "NSAbortModalException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nsabortprintingexception).
        abort_printing "NSAbortPrintingException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nsillegalselectorexception).
        illegal_selector "NSIllegalSelectorException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nsappkitvirtualmemoryexception).
        app_kit_virtual_memory "NSAppKitVirtualMemoryException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nsbadrtfdirectiveexception).
        bad_rtf_directive "NSBadRTFDirectiveException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nsbadrtffonttableexception).
        bad_rtf_font_table "NSBadRTFFontTableException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nsbadrtfstylesheetexception).
        bad_rtf_style_sheet "NSBadRTFStyleSheetException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nstypedstreamversionexception).
        typed_stream_version "NSTypedStreamVersionException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nstiffexception).
        tiff "NSTIFFException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nsprintpackageexception).
        print_package "NSPrintPackageException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nsbadrtfcolortableexception).
        bad_rtf_color_table "NSBadRTFColorTableException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nsdraggingexception).
        dragging "NSDraggingException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nscolorlistioexception).
        color_list_io "NSColorListIOException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nscolorlistnoteditableexception).
        color_list_not_editable "NSColorListNotEditableException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nsbadbitmapparametersexception).
        bad_bitmap_parameters "NSBadBitmapParametersException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nswindowservercommunicationexception).
        window_server_communication "NSWindowServerCommunicationException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nsfontunavailableexception).
        font_unavailable "NSFontUnavailableException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nsppdincludenotfoundexception).
        ppd_include_not_found "NSPPDIncludeNotFoundException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nsppdparseexception).
        ppd_parse "NSPPDParseException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nsppdincludestackoverflowexception).
        ppd_include_stack_overflow "NSPPDIncludeStackOverflowException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nsppdincludestackunderflowexception).
        ppd_include_stack_underflow "NSPPDIncludeStackUnderflowException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nsrtfpropertystackoverflowexception).
        rtf_property_stack_overflow "NSRTFPropertyStackOverflowException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nsappkitignoredexception).
        app_kit_ignored "NSAppKitIgnoredException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nsbadcomparisonexception).
        bad_comparison "NSBadComparisonException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nsimagecacheexception).
        image_cache "NSImageCacheException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nsnibloadingexception).
        nib_loading "NSNibLoadingException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nsbrowserillegaldelegateexception).
        browser_illegal_delegate "NSBrowserIllegalDelegateException"
    }

    name! {
        /// See [documentation](https://developer.apple.com/documentation/appkit/nsaccessibilityexception).
        accessibility "NSAccessibilityException"
    }

    name! {
        /// An exception raised when there is already an
        /// [`NSPrintOperation`](../app_kit/struct.NSPrintOperation.html) in
        /// process.
        ///
        /// See [documentation](https://developer.apple.com/documentation/appkit/nsprintoperationexistsexception).
        print_operation_exists "NSPrintOperationExistsException"
    }
}

/// UIKit exceptions.
///
/// Requires the **`ui_kit`** feature flag.
#[cfg(feature = "ui_kit")]
impl NSExceptionName {
    name! {
        /// The exception raised when a view controller or the app returns `0`
        /// instead of a valid set of supported interface orientation values.
        ///
        /// It is also thrown if the orientation returned by a view controller's
        /// [`preferredInterfaceOrientationForPresentation`](https://developer.apple.com/documentation/uikit/uiviewcontroller/1621438-preferredinterfaceorientationfor)
        /// method does not match one of the view controller’s supported
        /// orientations.
        ///
        /// See [documentation](https://developer.apple.com/documentation/uikit/uiapplicationinvalidinterfaceorientationexception).
        ui_application_invalid_interface_orientation "UIApplicationInvalidInterfaceOrientationException"
    }

    name! {
        /// The exception raised when a view controller hierarchy is
        /// inconsistent with the view hierarchy.
        ///
        /// See [documentation](https://developer.apple.com/documentation/uikit/uiviewcontrollerhierarchyinconsistencyexception).
        ui_view_controller_hierarchy_inconsistency "UIViewControllerHierarchyInconsistencyException"
    }
}