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
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
extern_class!(
/// A class representing a type in a type hierarchy.
///
/// Types may represent files on disk, abstract data types with no on-disk
/// representation, or even entirely unrelated hierarchical classification
/// systems such as hardware.
///
/// Older API that does not use
/// `UTType`typically uses an untyped
/// `NSString`or
/// `CFStringRef`to refer to a type by its identifier. To get the
/// identifier of a type for use with these APIs, use the
/// `identifier`property
/// of this class.
///
///
/// See also: https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/understanding_utis/
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/uniformtypeidentifiers/uttype?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct UTType;
);
unsafe impl Send for UTType {}
unsafe impl Sync for UTType {}
extern_conformance!(
unsafe impl NSCoding for UTType {}
);
extern_conformance!(
unsafe impl NSCopying for UTType {}
);
unsafe impl CopyingHelper for UTType {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for UTType {}
);
extern_conformance!(
unsafe impl NSSecureCoding for UTType {}
);
impl UTType {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
/// Create a type given a type identifier.
///
///
/// Parameter `identifier`: The type identifier.
///
///
/// Returns: A type, or
/// `nil`if the type identifier is not known to the system.
#[unsafe(method(typeWithIdentifier:))]
#[unsafe(method_family = none)]
pub fn typeWithIdentifier(identifier: &NSString) -> Option<Retained<Self>>;
/// Create a type given a filename extension that conforms to
/// `UTTypeData.`
///
/// Parameter `filenameExtension`: The filename extension for which a type is desired.
///
///
/// Returns: A type. If no types are known to the system with the specified
/// filename extension and conformance but the inputs were otherwise valid,
/// a dynamic type may be provided. If the inputs were not valid, returns
/// `nil.`
/// This method is equivalent to:
///
/// ```text
/// [UTType typeWithTag:filenameExtension tagClass:UTTagClassFilenameExtension conformingToType:UTTypeData]
/// ```
///
/// To get the type of a file on disk, use the
/// `NSURLContentTypeKey`property.
/// You should not attempt to derive the type of a file system object based
/// solely on its path extension.
#[unsafe(method(typeWithFilenameExtension:))]
#[unsafe(method_family = none)]
pub fn typeWithFilenameExtension(filename_extension: &NSString) -> Option<Retained<Self>>;
/// Create a type given a filename extension.
///
///
/// Parameter `filenameExtension`: The filename extension for which a type is desired.
///
/// Parameter `supertype`: Another type that the resulting type must conform to.
/// Typically, you would pass
/// `UTTypeData`or
/// `UTTypePackage.`
///
/// Returns: A type. If no types are known to the system with the specified
/// filename extension and conformance but the inputs were otherwise valid,
/// a dynamic type may be provided. If the inputs were not valid, returns
/// `nil.`
/// This method is equivalent to:
///
/// ```text
/// [UTType typeWithTag:filenameExtension tagClass:UTTagClassFilenameExtension conformingToType:supertype]
/// ```
///
/// To get the type of a file on disk, use the
/// `NSURLContentTypeKey`property.
/// You should not attempt to derive the type of a file system object based
/// solely on its path extension.
#[unsafe(method(typeWithFilenameExtension:conformingToType:))]
#[unsafe(method_family = none)]
pub fn typeWithFilenameExtension_conformingToType(
filename_extension: &NSString,
supertype: &UTType,
) -> Option<Retained<Self>>;
/// Create a type given a MIME type that conforms to
/// `UTTypeData.`
///
/// Parameter `mimeType`: The MIME type for which a type is desired.
///
///
/// Returns: A type. If no types are known to the system with the specified
/// MIME type and conformance but the inputs were otherwise valid, a dynamic
/// type may be provided. If the inputs were not valid, returns
/// `nil.`
/// This method is equivalent to:
///
/// ```text
/// [UTType typeWithTag:mimeType tagClass:UTTagClassMIMEType conformingToType:UTTypeData]
/// ```
#[unsafe(method(typeWithMIMEType:))]
#[unsafe(method_family = none)]
pub fn typeWithMIMEType(mime_type: &NSString) -> Option<Retained<Self>>;
/// Create a type given a MIME type.
///
///
/// Parameter `mimeType`: The MIME type for which a type is desired.
///
/// Parameter `supertype`: Another type that the resulting type must conform to.
/// Typically, you would pass
/// `UTTypeData.`
///
/// Returns: A type. If no types are known to the system with the specified
/// MIME type and conformance but the inputs were otherwise valid, a dynamic
/// type may be provided. If the inputs were not valid, returns
/// `nil.`
/// This method is equivalent to:
///
/// ```text
/// [UTType typeWithTag:mimeType tagClass:UTTagClassMIMEType conformingToType:supertype]
/// ```
#[unsafe(method(typeWithMIMEType:conformingToType:))]
#[unsafe(method_family = none)]
pub fn typeWithMIMEType_conformingToType(
mime_type: &NSString,
supertype: &UTType,
) -> Option<Retained<Self>>;
/// The receiver's identifier.
///
/// A type is
/// _identified__by_its Uniform Type Identifier (UTI), a
/// reverse-DNS string such as
/// `"public.jpeg"`or
/// `"com.adobe.pdf".`The type
/// itself
/// _has_a UTI, but is not itself the UTI. This terminology is not
/// consistently used across Apple's documentation.
#[unsafe(method(identifier))]
#[unsafe(method_family = none)]
pub fn identifier(&self) -> Retained<NSString>;
/// If available, the preferred (first available) tag of class
/// `UTTagClassFilenameExtension.`
/// Many uses of types require the generation of a filename (e.g. when saving a
/// file to disk.) If not
/// `nil,`the value of this property is the best
/// available filename extension for the given type. The value of this property
/// is equivalent to, but more efficient than:
///
/// ```text
/// type.tags[UTTagClassFilenameExtension].firstObject
/// ```
#[unsafe(method(preferredFilenameExtension))]
#[unsafe(method_family = none)]
pub fn preferredFilenameExtension(&self) -> Option<Retained<NSString>>;
/// If available, the preferred (first available) tag of class
/// `UTTagClassMIMEType.`
/// If not
/// `nil,`the value of this property is the best available MIME type
/// for the given type, according to its declaration. The value of this property
/// is equivalent to, but more efficient than:
///
/// ```text
/// type.tags[UTTagClassMIMEType].firstObject
/// ```
#[unsafe(method(preferredMIMEType))]
#[unsafe(method_family = none)]
pub fn preferredMIMEType(&self) -> Option<Retained<NSString>>;
/// The localized description of the type.
///
/// If the type does not provide a description, the system may search its
/// supertypes for one. Dynamic types never have localized descriptions even if
/// their supertypes do.
#[unsafe(method(localizedDescription))]
#[unsafe(method_family = none)]
pub fn localizedDescription(&self) -> Option<Retained<NSString>>;
/// The type's version.
///
/// Most types do not specify a version.
#[unsafe(method(version))]
#[unsafe(method_family = none)]
pub fn version(&self) -> Option<Retained<NSNumber>>;
/// The reference URL of the type.
///
/// A reference URL is a human-readable document describing a type. Most types
/// do not specify reference URLs.
///
///
/// Warning: This URL is not validated in any way by the system, nor is its
/// scheme or structure guaranteed in any way.
#[unsafe(method(referenceURL))]
#[unsafe(method_family = none)]
pub fn referenceURL(&self) -> Option<Retained<NSURL>>;
/// Whether or not the receiver is a dynamically generated type.
///
/// Dynamic types are recognized by the system, but may not be directly declared
/// or claimed by an application. They are used when a file is encountered whose
/// metadata has no corresponding type known to the system.
///
/// A type cannot be both declared
/// _and_dynamic.
#[unsafe(method(isDynamic))]
#[unsafe(method_family = none)]
pub fn isDynamic(&self) -> bool;
/// Whether or not the receiver is a type known to the system.
///
/// A type cannot be both declared
/// _and_dynamic.
#[unsafe(method(isDeclared))]
#[unsafe(method_family = none)]
pub fn isDeclared(&self) -> bool;
/// Whether or not the type is in the public domain.
///
/// Types in the public domain have identifiers starting with
/// `"public."`and
/// are generally defined by a standards body or by convention. They are never
/// dynamic.
#[unsafe(method(isPublicType))]
#[unsafe(method_family = none)]
pub fn isPublicType(&self) -> bool;
);
}
/// Conformance.
impl UTType {
extern_methods!(
/// Tests for a conformance relationship between the receiver and another
/// type.
///
///
/// Parameter `type`: The type against which conformance should be tested.
///
///
/// Returns: If the two types are equal, returns
/// `YES.`If the receiver
/// conforms, directly or indirectly, to
/// _type,_returns
/// `YES.`Otherwise,
/// returns
/// `NO.`
///
/// See also: -isSupertypeOfType:
///
/// See also: -isSubtypeOfType:
#[unsafe(method(conformsToType:))]
#[unsafe(method_family = none)]
pub fn conformsToType(&self, r#type: &UTType) -> bool;
/// Tests if the receiver is a supertype of another type.
///
///
/// Parameter `type`: The type against which conformance should be tested.
///
///
/// Returns: If
/// _type_conforms, directly or indirectly, to the receiver and is
/// not equal to it, returns
/// `YES.`Otherwise, returns
/// `NO.`
///
/// See also: -conformsToType:
///
/// See also: -isSubtypeOfType:
#[unsafe(method(isSupertypeOfType:))]
#[unsafe(method_family = none)]
pub fn isSupertypeOfType(&self, r#type: &UTType) -> bool;
/// Tests if the receiver is a subtype of another type.
///
///
/// Parameter `type`: The type against which conformance should be tested.
///
///
/// Returns: If the receiver conforms, directly or indirectly, to
/// _type_and is
/// not equal to it, returns
/// `YES.`Otherwise, returns
/// `NO.`
///
/// See also: -conformsToType:
///
/// See also: -isSupertypeOfType:
#[unsafe(method(isSubtypeOfType:))]
#[unsafe(method_family = none)]
pub fn isSubtypeOfType(&self, r#type: &UTType) -> bool;
/// The set of types to which the receiving type conforms, directly or
/// indirectly.
///
/// If you are just interested in checking if one type conforms to another, it
/// is more efficient to use
/// `-conformsToType:`than this property.
#[unsafe(method(supertypes))]
#[unsafe(method_family = none)]
pub fn supertypes(&self) -> Retained<NSSet<UTType>>;
);
}
/// UTTagSpecification.
impl UTType {
extern_methods!(
/// Create a type given a type tag.
///
///
/// Parameter `tag`: The tag, such as the path extension, for which a type is desired.
///
/// Parameter `tagClass`: The class of the tag, such as
/// `UTTagClassFilenameExtension.`
/// Parameter `supertype`: Another type that the resulting type must conform to. If
/// `nil,`no conformance is required.
///
///
/// Returns: A type. If no types are known to the system with the specified tag
/// but the inputs were otherwise valid, a dynamic type may be provided. If
/// the inputs were not valid, returns
/// `nil.`
#[unsafe(method(typeWithTag:tagClass:conformingToType:))]
#[unsafe(method_family = none)]
pub fn typeWithTag_tagClass_conformingToType(
tag: &NSString,
tag_class: &NSString,
supertype: Option<&UTType>,
) -> Option<Retained<Self>>;
/// Create an array of types given a type tag.
///
///
/// Parameter `tag`: The tag, such as the path extension, for which a set of types is
/// desired.
///
/// Parameter `tagClass`: The class of the tag, such as
/// `UTTagClassFilenameExtension.`
/// Parameter `supertype`: Another type that the resulting types must conform to. If
/// `nil,`no conformance is required.
///
///
/// Returns: An array of types, or the empty array if no such types were
/// available. If no types are known to the system with the specified tag
/// but the inputs were otherwise valid, a dynamic type may be provided.
#[unsafe(method(typesWithTag:tagClass:conformingToType:))]
#[unsafe(method_family = none)]
pub fn typesWithTag_tagClass_conformingToType(
tag: &NSString,
tag_class: &NSString,
supertype: Option<&UTType>,
) -> Retained<NSArray<UTType>>;
/// The tag specification dictionary of the type.
///
/// The system does not store tag information for non-standard tag classes. It
/// normalizes string values into arrays containing those strings. For instance,
/// a value of:
///
/// ```text
/// {
/// "public.mime-type": "x/y",
/// "nonstandard-tag-class": "abc",
/// }
/// ```
///
/// Is normalized to:
///
/// ```text
/// {
/// "public.mime-type": [ "x/y" ]
/// }
/// ```
///
/// If you are simply looking for the preferred filename extension or MIME
/// type of a type, it is more efficient for you to use the
/// `preferredFilenameExtension`and
/// `preferredMIMEType`properties
/// respectively.
#[unsafe(method(tags))]
#[unsafe(method_family = none)]
pub fn tags(&self) -> Retained<NSDictionary<NSString, NSArray<NSString>>>;
);
}
/// LocalConstants.
impl UTType {
extern_methods!(
/// Gets an active
/// `UTType`corresponding to a type that is declared as
/// "exported" by the current process.
///
///
/// Parameter `identifier`: The type identifier for which a type is desired.
///
///
/// Returns: A type.
///
/// Use this method to get types that are exported by your application. If
/// _identifier_does not correspond to any type known to the system, the
/// result is undefined.
///
/// Conformance to either
/// `UTTypeData`or
/// `UTTypePackage`is assumed.
///
/// You would generally use this method with
/// `dispatch_once():`
/// ```text
/// UTType *GetMyFileFormat(void) {
/// static UTType *result = nil;
///
/// static dispatch_once_t once;
/// dispatch_once(&once, ^ {
/// result = [UTType exportedTypeWithIdentifier:@"com.example.myfileformat"];
/// });
///
/// return result;
/// }
/// ```
#[unsafe(method(exportedTypeWithIdentifier:))]
#[unsafe(method_family = none)]
pub fn exportedTypeWithIdentifier(identifier: &NSString) -> Retained<UTType>;
/// Gets an active
/// `UTType`corresponding to a type that is declared as
/// "exported" by the current process.
///
///
/// Parameter `identifier`: The type identifier for which a type is desired.
///
/// Parameter `parentType`: A parent type that the resulting type is expected to
/// conform to.
///
///
/// Returns: A type.
///
/// Use this method to get types that are exported by your application. If
/// _identifier_does not correspond to any type known to the system, the
/// result is undefined.
///
/// You would generally use this method with
/// `dispatch_once():`
/// ```text
/// UTType *GetMyFileFormat(void) {
/// static UTType *result = nil;
///
/// static dispatch_once_t once;
/// dispatch_once(&once, ^ {
/// result = [UTType exportedTypeWithIdentifier:@"com.example.myfileformat" conformingToType:UTTypeData];
/// });
///
/// return result;
/// }
/// ```
#[unsafe(method(exportedTypeWithIdentifier:conformingToType:))]
#[unsafe(method_family = none)]
pub fn exportedTypeWithIdentifier_conformingToType(
identifier: &NSString,
parent_type: &UTType,
) -> Retained<UTType>;
/// Gets an active
/// `UTType`corresponding to a type that is declared as
/// "imported" by the current process.
///
///
/// Parameter `identifier`: The type identifier for which a type is desired.
///
///
/// Returns: A type whose identifier may or may not be equal to
/// _identifier,_but which is functionally equivalent.
///
/// Use this method to get types that are imported by your application. If
/// _identifier_does not correspond to any type known to the system, the
/// result is undefined.
///
/// Conformance to either
/// `UTTypeData`or
/// `UTTypePackage`is assumed.
///
/// You would generally use this method in the body of a funcion or method and
/// would
/// _not_use
/// `dispatch_once()`as the type can change over time:
///
/// ```text
/// UTType *GetCompetitorFileFormat(void) {
/// return [UTType importedTypeWithIdentifier:@"com.example.competitorfileformat"];
/// }
/// ```
///
/// In the general case, this method returns a type with the same identifier,
/// but if that type has a preferred filename extension and
/// _another_type is
/// the preferred type for that extension, then that
/// _other_type is
/// substituted.
#[unsafe(method(importedTypeWithIdentifier:))]
#[unsafe(method_family = none)]
pub fn importedTypeWithIdentifier(identifier: &NSString) -> Retained<UTType>;
/// Gets an active
/// `UTType`corresponding to a type that is declared as
/// "imported" by the current process.
///
///
/// Parameter `identifier`: The type identifier for which a type is desired.
///
/// Parameter `parentType`: A parent type that the resulting type is expected to
/// conform to.
///
///
/// Returns: A type whose identifier may or may not be equal to
/// _identifier,_but which is functionally equivalent.
///
/// Use this method to get types that are imported by your application. If
/// _identifier_does not correspond to any type known to the system, the
/// result is undefined.
///
/// You would generally use this method in the body of a funcion or method and
/// would
/// _not_use
/// `dispatch_once()`as the type can change over time:
///
/// ```text
/// UTType *GetCompetitorFileFormat(void) {
/// return [UTType importedTypeWithIdentifier:@"com.example.competitorfileformat" conformingToType:UTTypeData];
/// }
/// ```
///
/// In the general case, this method returns a type with the same identifier,
/// but if that type has a preferred filename extension and
/// _another_type is
/// the preferred type for that extension, then that
/// _other_type is
/// substituted.
#[unsafe(method(importedTypeWithIdentifier:conformingToType:))]
#[unsafe(method_family = none)]
pub fn importedTypeWithIdentifier_conformingToType(
identifier: &NSString,
parent_type: &UTType,
) -> Retained<UTType>;
);
}