objc2-foundation 0.3.2

Bindings to the Foundation framework
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
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
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogresskind?language=objc)
// NS_TYPED_EXTENSIBLE_ENUM
#[cfg(feature = "NSString")]
pub type NSProgressKind = NSString;

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressuserinfokey?language=objc)
// NS_TYPED_EXTENSIBLE_ENUM
#[cfg(feature = "NSString")]
pub type NSProgressUserInfoKey = NSString;

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfileoperationkind?language=objc)
// NS_TYPED_EXTENSIBLE_ENUM
#[cfg(feature = "NSString")]
pub type NSProgressFileOperationKind = NSString;

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressunpublishinghandler?language=objc)
#[cfg(feature = "block2")]
pub type NSProgressUnpublishingHandler = *mut block2::DynBlock<dyn Fn()>;

/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogresspublishinghandler?language=objc)
#[cfg(feature = "block2")]
pub type NSProgressPublishingHandler =
    *mut block2::DynBlock<dyn Fn(NonNull<NSProgress>) -> NSProgressUnpublishingHandler>;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogress?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSProgress;
);

unsafe impl Send for NSProgress {}

unsafe impl Sync for NSProgress {}

extern_conformance!(
    unsafe impl NSObjectProtocol for NSProgress {}
);

impl NSProgress {
    extern_methods!(
        #[unsafe(method(currentProgress))]
        #[unsafe(method_family = none)]
        pub fn currentProgress() -> Option<Retained<NSProgress>>;

        #[unsafe(method(progressWithTotalUnitCount:))]
        #[unsafe(method_family = none)]
        pub fn progressWithTotalUnitCount(unit_count: i64) -> Retained<NSProgress>;

        #[unsafe(method(discreteProgressWithTotalUnitCount:))]
        #[unsafe(method_family = none)]
        pub fn discreteProgressWithTotalUnitCount(unit_count: i64) -> Retained<NSProgress>;

        #[unsafe(method(progressWithTotalUnitCount:parent:pendingUnitCount:))]
        #[unsafe(method_family = none)]
        pub fn progressWithTotalUnitCount_parent_pendingUnitCount(
            unit_count: i64,
            parent: &NSProgress,
            portion_of_parent_total_unit_count: i64,
        ) -> Retained<NSProgress>;

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        /// # Safety
        ///
        /// `user_info_or_nil` generic should be of the correct type.
        #[unsafe(method(initWithParent:userInfo:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithParent_userInfo(
            this: Allocated<Self>,
            parent_progress_or_nil: Option<&NSProgress>,
            user_info_or_nil: Option<&NSDictionary<NSProgressUserInfoKey, AnyObject>>,
        ) -> Retained<Self>;

        #[unsafe(method(becomeCurrentWithPendingUnitCount:))]
        #[unsafe(method_family = none)]
        pub fn becomeCurrentWithPendingUnitCount(&self, unit_count: i64);

        #[cfg(feature = "block2")]
        #[unsafe(method(performAsCurrentWithPendingUnitCount:usingBlock:))]
        #[unsafe(method_family = none)]
        pub fn performAsCurrentWithPendingUnitCount_usingBlock(
            &self,
            unit_count: i64,
            work: &block2::DynBlock<dyn Fn() + '_>,
        );

        #[unsafe(method(resignCurrent))]
        #[unsafe(method_family = none)]
        pub fn resignCurrent(&self);

        #[unsafe(method(addChild:withPendingUnitCount:))]
        #[unsafe(method_family = none)]
        pub fn addChild_withPendingUnitCount(&self, child: &NSProgress, in_unit_count: i64);

        #[unsafe(method(totalUnitCount))]
        #[unsafe(method_family = none)]
        pub fn totalUnitCount(&self) -> i64;

        /// Setter for [`totalUnitCount`][Self::totalUnitCount].
        #[unsafe(method(setTotalUnitCount:))]
        #[unsafe(method_family = none)]
        pub fn setTotalUnitCount(&self, total_unit_count: i64);

        #[unsafe(method(completedUnitCount))]
        #[unsafe(method_family = none)]
        pub fn completedUnitCount(&self) -> i64;

        /// Setter for [`completedUnitCount`][Self::completedUnitCount].
        #[unsafe(method(setCompletedUnitCount:))]
        #[unsafe(method_family = none)]
        pub fn setCompletedUnitCount(&self, completed_unit_count: i64);

        #[cfg(feature = "NSString")]
        #[unsafe(method(localizedDescription))]
        #[unsafe(method_family = none)]
        pub fn localizedDescription(&self) -> Retained<NSString>;

        #[cfg(feature = "NSString")]
        /// Setter for [`localizedDescription`][Self::localizedDescription].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        #[unsafe(method(setLocalizedDescription:))]
        #[unsafe(method_family = none)]
        pub fn setLocalizedDescription(&self, localized_description: Option<&NSString>);

        #[cfg(feature = "NSString")]
        #[unsafe(method(localizedAdditionalDescription))]
        #[unsafe(method_family = none)]
        pub fn localizedAdditionalDescription(&self) -> Retained<NSString>;

        #[cfg(feature = "NSString")]
        /// Setter for [`localizedAdditionalDescription`][Self::localizedAdditionalDescription].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        #[unsafe(method(setLocalizedAdditionalDescription:))]
        #[unsafe(method_family = none)]
        pub fn setLocalizedAdditionalDescription(
            &self,
            localized_additional_description: Option<&NSString>,
        );

        #[unsafe(method(isCancellable))]
        #[unsafe(method_family = none)]
        pub fn isCancellable(&self) -> bool;

        /// Setter for [`isCancellable`][Self::isCancellable].
        #[unsafe(method(setCancellable:))]
        #[unsafe(method_family = none)]
        pub fn setCancellable(&self, cancellable: bool);

        #[unsafe(method(isPausable))]
        #[unsafe(method_family = none)]
        pub fn isPausable(&self) -> bool;

        /// Setter for [`isPausable`][Self::isPausable].
        #[unsafe(method(setPausable:))]
        #[unsafe(method_family = none)]
        pub fn setPausable(&self, pausable: bool);

        #[unsafe(method(isCancelled))]
        #[unsafe(method_family = none)]
        pub fn isCancelled(&self) -> bool;

        #[unsafe(method(isPaused))]
        #[unsafe(method_family = none)]
        pub fn isPaused(&self) -> bool;

        #[cfg(feature = "block2")]
        /// # Safety
        ///
        /// The returned block must be sendable.
        #[unsafe(method(cancellationHandler))]
        #[unsafe(method_family = none)]
        pub unsafe fn cancellationHandler(&self) -> *mut block2::DynBlock<dyn Fn()>;

        #[cfg(feature = "block2")]
        /// Setter for [`cancellationHandler`][Self::cancellationHandler].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `cancellation_handler` block must be sendable.
        #[unsafe(method(setCancellationHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setCancellationHandler(
            &self,
            cancellation_handler: Option<&block2::DynBlock<dyn Fn()>>,
        );

        #[cfg(feature = "block2")]
        /// # Safety
        ///
        /// The returned block must be sendable.
        #[unsafe(method(pausingHandler))]
        #[unsafe(method_family = none)]
        pub unsafe fn pausingHandler(&self) -> *mut block2::DynBlock<dyn Fn()>;

        #[cfg(feature = "block2")]
        /// Setter for [`pausingHandler`][Self::pausingHandler].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `pausing_handler` block must be sendable.
        #[unsafe(method(setPausingHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPausingHandler(
            &self,
            pausing_handler: Option<&block2::DynBlock<dyn Fn()>>,
        );

        #[cfg(feature = "block2")]
        /// # Safety
        ///
        /// The returned block must be sendable.
        #[unsafe(method(resumingHandler))]
        #[unsafe(method_family = none)]
        pub unsafe fn resumingHandler(&self) -> *mut block2::DynBlock<dyn Fn()>;

        #[cfg(feature = "block2")]
        /// Setter for [`resumingHandler`][Self::resumingHandler].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `resuming_handler` block must be sendable.
        #[unsafe(method(setResumingHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setResumingHandler(
            &self,
            resuming_handler: Option<&block2::DynBlock<dyn Fn()>>,
        );

        #[cfg(feature = "NSString")]
        /// # Safety
        ///
        /// `object_or_nil` should be of the correct type.
        #[unsafe(method(setUserInfoObject:forKey:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setUserInfoObject_forKey(
            &self,
            object_or_nil: Option<&AnyObject>,
            key: &NSProgressUserInfoKey,
        );

        #[unsafe(method(isIndeterminate))]
        #[unsafe(method_family = none)]
        pub fn isIndeterminate(&self) -> bool;

        #[unsafe(method(fractionCompleted))]
        #[unsafe(method_family = none)]
        pub fn fractionCompleted(&self) -> c_double;

        #[unsafe(method(isFinished))]
        #[unsafe(method_family = none)]
        pub fn isFinished(&self) -> bool;

        #[unsafe(method(cancel))]
        #[unsafe(method_family = none)]
        pub fn cancel(&self);

        #[unsafe(method(pause))]
        #[unsafe(method_family = none)]
        pub fn pause(&self);

        #[unsafe(method(resume))]
        #[unsafe(method_family = none)]
        pub fn resume(&self);

        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
        #[unsafe(method(userInfo))]
        #[unsafe(method_family = none)]
        pub fn userInfo(&self) -> Retained<NSDictionary<NSProgressUserInfoKey, AnyObject>>;

        #[cfg(feature = "NSString")]
        #[unsafe(method(kind))]
        #[unsafe(method_family = none)]
        pub fn kind(&self) -> Option<Retained<NSProgressKind>>;

        #[cfg(feature = "NSString")]
        /// Setter for [`kind`][Self::kind].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        #[unsafe(method(setKind:))]
        #[unsafe(method_family = none)]
        pub fn setKind(&self, kind: Option<&NSProgressKind>);

        #[cfg(feature = "NSValue")]
        #[unsafe(method(estimatedTimeRemaining))]
        #[unsafe(method_family = none)]
        pub fn estimatedTimeRemaining(&self) -> Option<Retained<NSNumber>>;

        #[cfg(feature = "NSValue")]
        /// Setter for [`estimatedTimeRemaining`][Self::estimatedTimeRemaining].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        #[unsafe(method(setEstimatedTimeRemaining:))]
        #[unsafe(method_family = none)]
        pub fn setEstimatedTimeRemaining(&self, estimated_time_remaining: Option<&NSNumber>);

        #[cfg(feature = "NSValue")]
        #[unsafe(method(throughput))]
        #[unsafe(method_family = none)]
        pub fn throughput(&self) -> Option<Retained<NSNumber>>;

        #[cfg(feature = "NSValue")]
        /// Setter for [`throughput`][Self::throughput].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        #[unsafe(method(setThroughput:))]
        #[unsafe(method_family = none)]
        pub fn setThroughput(&self, throughput: Option<&NSNumber>);

        #[cfg(feature = "NSString")]
        #[unsafe(method(fileOperationKind))]
        #[unsafe(method_family = none)]
        pub fn fileOperationKind(&self) -> Option<Retained<NSProgressFileOperationKind>>;

        #[cfg(feature = "NSString")]
        /// Setter for [`fileOperationKind`][Self::fileOperationKind].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        #[unsafe(method(setFileOperationKind:))]
        #[unsafe(method_family = none)]
        pub fn setFileOperationKind(
            &self,
            file_operation_kind: Option<&NSProgressFileOperationKind>,
        );

        #[cfg(feature = "NSURL")]
        #[unsafe(method(fileURL))]
        #[unsafe(method_family = none)]
        pub fn fileURL(&self) -> Option<Retained<NSURL>>;

        #[cfg(feature = "NSURL")]
        /// Setter for [`fileURL`][Self::fileURL].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        #[unsafe(method(setFileURL:))]
        #[unsafe(method_family = none)]
        pub fn setFileURL(&self, file_url: Option<&NSURL>);

        #[cfg(feature = "NSValue")]
        #[unsafe(method(fileTotalCount))]
        #[unsafe(method_family = none)]
        pub fn fileTotalCount(&self) -> Option<Retained<NSNumber>>;

        #[cfg(feature = "NSValue")]
        /// Setter for [`fileTotalCount`][Self::fileTotalCount].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        #[unsafe(method(setFileTotalCount:))]
        #[unsafe(method_family = none)]
        pub fn setFileTotalCount(&self, file_total_count: Option<&NSNumber>);

        #[cfg(feature = "NSValue")]
        #[unsafe(method(fileCompletedCount))]
        #[unsafe(method_family = none)]
        pub fn fileCompletedCount(&self) -> Option<Retained<NSNumber>>;

        #[cfg(feature = "NSValue")]
        /// Setter for [`fileCompletedCount`][Self::fileCompletedCount].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        #[unsafe(method(setFileCompletedCount:))]
        #[unsafe(method_family = none)]
        pub fn setFileCompletedCount(&self, file_completed_count: Option<&NSNumber>);

        #[unsafe(method(publish))]
        #[unsafe(method_family = none)]
        pub fn publish(&self);

        #[unsafe(method(unpublish))]
        #[unsafe(method_family = none)]
        pub fn unpublish(&self);

        #[cfg(all(feature = "NSURL", feature = "block2"))]
        /// # Safety
        ///
        /// `publishing_handler` must be a valid pointer.
        #[unsafe(method(addSubscriberForFileURL:withPublishingHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addSubscriberForFileURL_withPublishingHandler(
            url: &NSURL,
            publishing_handler: NSProgressPublishingHandler,
        ) -> Retained<AnyObject>;

        /// # Safety
        ///
        /// `subscriber` should be of the correct type.
        #[unsafe(method(removeSubscriber:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeSubscriber(subscriber: &AnyObject);

        #[unsafe(method(isOld))]
        #[unsafe(method_family = none)]
        pub fn isOld(&self) -> bool;
    );
}

/// Methods declared on superclass `NSObject`.
impl NSProgress {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new() -> Retained<Self>;
    );
}

impl DefaultRetained for NSProgress {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressreporting?language=objc)
    pub unsafe trait NSProgressReporting: NSObjectProtocol {
        #[unsafe(method(progress))]
        #[unsafe(method_family = none)]
        fn progress(&self) -> Retained<NSProgress>;
    }
);

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressestimatedtimeremainingkey?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSProgressEstimatedTimeRemainingKey: &'static NSProgressUserInfoKey;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressthroughputkey?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSProgressThroughputKey: &'static NSProgressUserInfoKey;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogresskindfile?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSProgressKindFile: &'static NSProgressKind;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfileoperationkindkey?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSProgressFileOperationKindKey: &'static NSProgressUserInfoKey;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfileoperationkinddownloading?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSProgressFileOperationKindDownloading: &'static NSProgressFileOperationKind;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfileoperationkinddecompressingafterdownloading?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSProgressFileOperationKindDecompressingAfterDownloading:
        &'static NSProgressFileOperationKind;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfileoperationkindreceiving?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSProgressFileOperationKindReceiving: &'static NSProgressFileOperationKind;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfileoperationkindcopying?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSProgressFileOperationKindCopying: &'static NSProgressFileOperationKind;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfileoperationkinduploading?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSProgressFileOperationKindUploading: &'static NSProgressFileOperationKind;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfileoperationkindduplicating?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSProgressFileOperationKindDuplicating: &'static NSProgressFileOperationKind;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfileurlkey?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSProgressFileURLKey: &'static NSProgressUserInfoKey;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfiletotalcountkey?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSProgressFileTotalCountKey: &'static NSProgressUserInfoKey;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfilecompletedcountkey?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSProgressFileCompletedCountKey: &'static NSProgressUserInfoKey;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfileanimationimagekey?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSProgressFileAnimationImageKey: &'static NSProgressUserInfoKey;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfileanimationimageoriginalrectkey?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSProgressFileAnimationImageOriginalRectKey: &'static NSProgressUserInfoKey;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfileiconkey?language=objc)
    #[cfg(feature = "NSString")]
    pub static NSProgressFileIconKey: &'static NSProgressUserInfoKey;
}