objc2_foundation/generated/
NSProgress.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogresskind?language=objc)
10// NS_TYPED_EXTENSIBLE_ENUM
11#[cfg(feature = "NSString")]
12pub type NSProgressKind = NSString;
13
14/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressuserinfokey?language=objc)
15// NS_TYPED_EXTENSIBLE_ENUM
16#[cfg(feature = "NSString")]
17pub type NSProgressUserInfoKey = NSString;
18
19/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfileoperationkind?language=objc)
20// NS_TYPED_EXTENSIBLE_ENUM
21#[cfg(feature = "NSString")]
22pub type NSProgressFileOperationKind = NSString;
23
24/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressunpublishinghandler?language=objc)
25#[cfg(feature = "block2")]
26pub type NSProgressUnpublishingHandler = *mut block2::DynBlock<dyn Fn()>;
27
28/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogresspublishinghandler?language=objc)
29#[cfg(feature = "block2")]
30pub type NSProgressPublishingHandler =
31    *mut block2::DynBlock<dyn Fn(NonNull<NSProgress>) -> NSProgressUnpublishingHandler>;
32
33extern_class!(
34    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogress?language=objc)
35    #[unsafe(super(NSObject))]
36    #[derive(Debug, PartialEq, Eq, Hash)]
37    pub struct NSProgress;
38);
39
40unsafe impl Send for NSProgress {}
41
42unsafe impl Sync for NSProgress {}
43
44extern_conformance!(
45    unsafe impl NSObjectProtocol for NSProgress {}
46);
47
48impl NSProgress {
49    extern_methods!(
50        #[unsafe(method(currentProgress))]
51        #[unsafe(method_family = none)]
52        pub fn currentProgress() -> Option<Retained<NSProgress>>;
53
54        #[unsafe(method(progressWithTotalUnitCount:))]
55        #[unsafe(method_family = none)]
56        pub fn progressWithTotalUnitCount(unit_count: i64) -> Retained<NSProgress>;
57
58        #[unsafe(method(discreteProgressWithTotalUnitCount:))]
59        #[unsafe(method_family = none)]
60        pub fn discreteProgressWithTotalUnitCount(unit_count: i64) -> Retained<NSProgress>;
61
62        #[unsafe(method(progressWithTotalUnitCount:parent:pendingUnitCount:))]
63        #[unsafe(method_family = none)]
64        pub fn progressWithTotalUnitCount_parent_pendingUnitCount(
65            unit_count: i64,
66            parent: &NSProgress,
67            portion_of_parent_total_unit_count: i64,
68        ) -> Retained<NSProgress>;
69
70        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
71        /// # Safety
72        ///
73        /// `user_info_or_nil` generic should be of the correct type.
74        #[unsafe(method(initWithParent:userInfo:))]
75        #[unsafe(method_family = init)]
76        pub unsafe fn initWithParent_userInfo(
77            this: Allocated<Self>,
78            parent_progress_or_nil: Option<&NSProgress>,
79            user_info_or_nil: Option<&NSDictionary<NSProgressUserInfoKey, AnyObject>>,
80        ) -> Retained<Self>;
81
82        #[unsafe(method(becomeCurrentWithPendingUnitCount:))]
83        #[unsafe(method_family = none)]
84        pub fn becomeCurrentWithPendingUnitCount(&self, unit_count: i64);
85
86        #[cfg(feature = "block2")]
87        #[unsafe(method(performAsCurrentWithPendingUnitCount:usingBlock:))]
88        #[unsafe(method_family = none)]
89        pub fn performAsCurrentWithPendingUnitCount_usingBlock(
90            &self,
91            unit_count: i64,
92            work: &block2::DynBlock<dyn Fn() + '_>,
93        );
94
95        #[unsafe(method(resignCurrent))]
96        #[unsafe(method_family = none)]
97        pub fn resignCurrent(&self);
98
99        #[unsafe(method(addChild:withPendingUnitCount:))]
100        #[unsafe(method_family = none)]
101        pub fn addChild_withPendingUnitCount(&self, child: &NSProgress, in_unit_count: i64);
102
103        #[unsafe(method(totalUnitCount))]
104        #[unsafe(method_family = none)]
105        pub fn totalUnitCount(&self) -> i64;
106
107        /// Setter for [`totalUnitCount`][Self::totalUnitCount].
108        #[unsafe(method(setTotalUnitCount:))]
109        #[unsafe(method_family = none)]
110        pub fn setTotalUnitCount(&self, total_unit_count: i64);
111
112        #[unsafe(method(completedUnitCount))]
113        #[unsafe(method_family = none)]
114        pub fn completedUnitCount(&self) -> i64;
115
116        /// Setter for [`completedUnitCount`][Self::completedUnitCount].
117        #[unsafe(method(setCompletedUnitCount:))]
118        #[unsafe(method_family = none)]
119        pub fn setCompletedUnitCount(&self, completed_unit_count: i64);
120
121        #[cfg(feature = "NSString")]
122        #[unsafe(method(localizedDescription))]
123        #[unsafe(method_family = none)]
124        pub fn localizedDescription(&self) -> Retained<NSString>;
125
126        #[cfg(feature = "NSString")]
127        /// Setter for [`localizedDescription`][Self::localizedDescription].
128        ///
129        /// This is [copied][crate::NSCopying::copy] when set.
130        #[unsafe(method(setLocalizedDescription:))]
131        #[unsafe(method_family = none)]
132        pub fn setLocalizedDescription(&self, localized_description: Option<&NSString>);
133
134        #[cfg(feature = "NSString")]
135        #[unsafe(method(localizedAdditionalDescription))]
136        #[unsafe(method_family = none)]
137        pub fn localizedAdditionalDescription(&self) -> Retained<NSString>;
138
139        #[cfg(feature = "NSString")]
140        /// Setter for [`localizedAdditionalDescription`][Self::localizedAdditionalDescription].
141        ///
142        /// This is [copied][crate::NSCopying::copy] when set.
143        #[unsafe(method(setLocalizedAdditionalDescription:))]
144        #[unsafe(method_family = none)]
145        pub fn setLocalizedAdditionalDescription(
146            &self,
147            localized_additional_description: Option<&NSString>,
148        );
149
150        #[unsafe(method(isCancellable))]
151        #[unsafe(method_family = none)]
152        pub fn isCancellable(&self) -> bool;
153
154        /// Setter for [`isCancellable`][Self::isCancellable].
155        #[unsafe(method(setCancellable:))]
156        #[unsafe(method_family = none)]
157        pub fn setCancellable(&self, cancellable: bool);
158
159        #[unsafe(method(isPausable))]
160        #[unsafe(method_family = none)]
161        pub fn isPausable(&self) -> bool;
162
163        /// Setter for [`isPausable`][Self::isPausable].
164        #[unsafe(method(setPausable:))]
165        #[unsafe(method_family = none)]
166        pub fn setPausable(&self, pausable: bool);
167
168        #[unsafe(method(isCancelled))]
169        #[unsafe(method_family = none)]
170        pub fn isCancelled(&self) -> bool;
171
172        #[unsafe(method(isPaused))]
173        #[unsafe(method_family = none)]
174        pub fn isPaused(&self) -> bool;
175
176        #[cfg(feature = "block2")]
177        /// # Safety
178        ///
179        /// The returned block must be sendable.
180        #[unsafe(method(cancellationHandler))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn cancellationHandler(&self) -> *mut block2::DynBlock<dyn Fn()>;
183
184        #[cfg(feature = "block2")]
185        /// Setter for [`cancellationHandler`][Self::cancellationHandler].
186        ///
187        /// This is [copied][crate::NSCopying::copy] when set.
188        ///
189        /// # Safety
190        ///
191        /// `cancellation_handler` block must be sendable.
192        #[unsafe(method(setCancellationHandler:))]
193        #[unsafe(method_family = none)]
194        pub unsafe fn setCancellationHandler(
195            &self,
196            cancellation_handler: Option<&block2::DynBlock<dyn Fn()>>,
197        );
198
199        #[cfg(feature = "block2")]
200        /// # Safety
201        ///
202        /// The returned block must be sendable.
203        #[unsafe(method(pausingHandler))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn pausingHandler(&self) -> *mut block2::DynBlock<dyn Fn()>;
206
207        #[cfg(feature = "block2")]
208        /// Setter for [`pausingHandler`][Self::pausingHandler].
209        ///
210        /// This is [copied][crate::NSCopying::copy] when set.
211        ///
212        /// # Safety
213        ///
214        /// `pausing_handler` block must be sendable.
215        #[unsafe(method(setPausingHandler:))]
216        #[unsafe(method_family = none)]
217        pub unsafe fn setPausingHandler(
218            &self,
219            pausing_handler: Option<&block2::DynBlock<dyn Fn()>>,
220        );
221
222        #[cfg(feature = "block2")]
223        /// # Safety
224        ///
225        /// The returned block must be sendable.
226        #[unsafe(method(resumingHandler))]
227        #[unsafe(method_family = none)]
228        pub unsafe fn resumingHandler(&self) -> *mut block2::DynBlock<dyn Fn()>;
229
230        #[cfg(feature = "block2")]
231        /// Setter for [`resumingHandler`][Self::resumingHandler].
232        ///
233        /// This is [copied][crate::NSCopying::copy] when set.
234        ///
235        /// # Safety
236        ///
237        /// `resuming_handler` block must be sendable.
238        #[unsafe(method(setResumingHandler:))]
239        #[unsafe(method_family = none)]
240        pub unsafe fn setResumingHandler(
241            &self,
242            resuming_handler: Option<&block2::DynBlock<dyn Fn()>>,
243        );
244
245        #[cfg(feature = "NSString")]
246        /// # Safety
247        ///
248        /// `object_or_nil` should be of the correct type.
249        #[unsafe(method(setUserInfoObject:forKey:))]
250        #[unsafe(method_family = none)]
251        pub unsafe fn setUserInfoObject_forKey(
252            &self,
253            object_or_nil: Option<&AnyObject>,
254            key: &NSProgressUserInfoKey,
255        );
256
257        #[unsafe(method(isIndeterminate))]
258        #[unsafe(method_family = none)]
259        pub fn isIndeterminate(&self) -> bool;
260
261        #[unsafe(method(fractionCompleted))]
262        #[unsafe(method_family = none)]
263        pub fn fractionCompleted(&self) -> c_double;
264
265        #[unsafe(method(isFinished))]
266        #[unsafe(method_family = none)]
267        pub fn isFinished(&self) -> bool;
268
269        #[unsafe(method(cancel))]
270        #[unsafe(method_family = none)]
271        pub fn cancel(&self);
272
273        #[unsafe(method(pause))]
274        #[unsafe(method_family = none)]
275        pub fn pause(&self);
276
277        #[unsafe(method(resume))]
278        #[unsafe(method_family = none)]
279        pub fn resume(&self);
280
281        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
282        #[unsafe(method(userInfo))]
283        #[unsafe(method_family = none)]
284        pub fn userInfo(&self) -> Retained<NSDictionary<NSProgressUserInfoKey, AnyObject>>;
285
286        #[cfg(feature = "NSString")]
287        #[unsafe(method(kind))]
288        #[unsafe(method_family = none)]
289        pub fn kind(&self) -> Option<Retained<NSProgressKind>>;
290
291        #[cfg(feature = "NSString")]
292        /// Setter for [`kind`][Self::kind].
293        ///
294        /// This is [copied][crate::NSCopying::copy] when set.
295        #[unsafe(method(setKind:))]
296        #[unsafe(method_family = none)]
297        pub fn setKind(&self, kind: Option<&NSProgressKind>);
298
299        #[cfg(feature = "NSValue")]
300        #[unsafe(method(estimatedTimeRemaining))]
301        #[unsafe(method_family = none)]
302        pub fn estimatedTimeRemaining(&self) -> Option<Retained<NSNumber>>;
303
304        #[cfg(feature = "NSValue")]
305        /// Setter for [`estimatedTimeRemaining`][Self::estimatedTimeRemaining].
306        ///
307        /// This is [copied][crate::NSCopying::copy] when set.
308        #[unsafe(method(setEstimatedTimeRemaining:))]
309        #[unsafe(method_family = none)]
310        pub fn setEstimatedTimeRemaining(&self, estimated_time_remaining: Option<&NSNumber>);
311
312        #[cfg(feature = "NSValue")]
313        #[unsafe(method(throughput))]
314        #[unsafe(method_family = none)]
315        pub fn throughput(&self) -> Option<Retained<NSNumber>>;
316
317        #[cfg(feature = "NSValue")]
318        /// Setter for [`throughput`][Self::throughput].
319        ///
320        /// This is [copied][crate::NSCopying::copy] when set.
321        #[unsafe(method(setThroughput:))]
322        #[unsafe(method_family = none)]
323        pub fn setThroughput(&self, throughput: Option<&NSNumber>);
324
325        #[cfg(feature = "NSString")]
326        #[unsafe(method(fileOperationKind))]
327        #[unsafe(method_family = none)]
328        pub fn fileOperationKind(&self) -> Option<Retained<NSProgressFileOperationKind>>;
329
330        #[cfg(feature = "NSString")]
331        /// Setter for [`fileOperationKind`][Self::fileOperationKind].
332        ///
333        /// This is [copied][crate::NSCopying::copy] when set.
334        #[unsafe(method(setFileOperationKind:))]
335        #[unsafe(method_family = none)]
336        pub fn setFileOperationKind(
337            &self,
338            file_operation_kind: Option<&NSProgressFileOperationKind>,
339        );
340
341        #[cfg(feature = "NSURL")]
342        #[unsafe(method(fileURL))]
343        #[unsafe(method_family = none)]
344        pub fn fileURL(&self) -> Option<Retained<NSURL>>;
345
346        #[cfg(feature = "NSURL")]
347        /// Setter for [`fileURL`][Self::fileURL].
348        ///
349        /// This is [copied][crate::NSCopying::copy] when set.
350        #[unsafe(method(setFileURL:))]
351        #[unsafe(method_family = none)]
352        pub fn setFileURL(&self, file_url: Option<&NSURL>);
353
354        #[cfg(feature = "NSValue")]
355        #[unsafe(method(fileTotalCount))]
356        #[unsafe(method_family = none)]
357        pub fn fileTotalCount(&self) -> Option<Retained<NSNumber>>;
358
359        #[cfg(feature = "NSValue")]
360        /// Setter for [`fileTotalCount`][Self::fileTotalCount].
361        ///
362        /// This is [copied][crate::NSCopying::copy] when set.
363        #[unsafe(method(setFileTotalCount:))]
364        #[unsafe(method_family = none)]
365        pub fn setFileTotalCount(&self, file_total_count: Option<&NSNumber>);
366
367        #[cfg(feature = "NSValue")]
368        #[unsafe(method(fileCompletedCount))]
369        #[unsafe(method_family = none)]
370        pub fn fileCompletedCount(&self) -> Option<Retained<NSNumber>>;
371
372        #[cfg(feature = "NSValue")]
373        /// Setter for [`fileCompletedCount`][Self::fileCompletedCount].
374        ///
375        /// This is [copied][crate::NSCopying::copy] when set.
376        #[unsafe(method(setFileCompletedCount:))]
377        #[unsafe(method_family = none)]
378        pub fn setFileCompletedCount(&self, file_completed_count: Option<&NSNumber>);
379
380        #[unsafe(method(publish))]
381        #[unsafe(method_family = none)]
382        pub fn publish(&self);
383
384        #[unsafe(method(unpublish))]
385        #[unsafe(method_family = none)]
386        pub fn unpublish(&self);
387
388        #[cfg(all(feature = "NSURL", feature = "block2"))]
389        /// # Safety
390        ///
391        /// `publishing_handler` must be a valid pointer.
392        #[unsafe(method(addSubscriberForFileURL:withPublishingHandler:))]
393        #[unsafe(method_family = none)]
394        pub unsafe fn addSubscriberForFileURL_withPublishingHandler(
395            url: &NSURL,
396            publishing_handler: NSProgressPublishingHandler,
397        ) -> Retained<AnyObject>;
398
399        /// # Safety
400        ///
401        /// `subscriber` should be of the correct type.
402        #[unsafe(method(removeSubscriber:))]
403        #[unsafe(method_family = none)]
404        pub unsafe fn removeSubscriber(subscriber: &AnyObject);
405
406        #[unsafe(method(isOld))]
407        #[unsafe(method_family = none)]
408        pub fn isOld(&self) -> bool;
409    );
410}
411
412/// Methods declared on superclass `NSObject`.
413impl NSProgress {
414    extern_methods!(
415        #[unsafe(method(init))]
416        #[unsafe(method_family = init)]
417        pub fn init(this: Allocated<Self>) -> Retained<Self>;
418
419        #[unsafe(method(new))]
420        #[unsafe(method_family = new)]
421        pub fn new() -> Retained<Self>;
422    );
423}
424
425impl DefaultRetained for NSProgress {
426    #[inline]
427    fn default_retained() -> Retained<Self> {
428        Self::new()
429    }
430}
431
432extern_protocol!(
433    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressreporting?language=objc)
434    pub unsafe trait NSProgressReporting: NSObjectProtocol {
435        #[unsafe(method(progress))]
436        #[unsafe(method_family = none)]
437        fn progress(&self) -> Retained<NSProgress>;
438    }
439);
440
441extern "C" {
442    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressestimatedtimeremainingkey?language=objc)
443    #[cfg(feature = "NSString")]
444    pub static NSProgressEstimatedTimeRemainingKey: &'static NSProgressUserInfoKey;
445}
446
447extern "C" {
448    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressthroughputkey?language=objc)
449    #[cfg(feature = "NSString")]
450    pub static NSProgressThroughputKey: &'static NSProgressUserInfoKey;
451}
452
453extern "C" {
454    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogresskindfile?language=objc)
455    #[cfg(feature = "NSString")]
456    pub static NSProgressKindFile: &'static NSProgressKind;
457}
458
459extern "C" {
460    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfileoperationkindkey?language=objc)
461    #[cfg(feature = "NSString")]
462    pub static NSProgressFileOperationKindKey: &'static NSProgressUserInfoKey;
463}
464
465extern "C" {
466    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfileoperationkinddownloading?language=objc)
467    #[cfg(feature = "NSString")]
468    pub static NSProgressFileOperationKindDownloading: &'static NSProgressFileOperationKind;
469}
470
471extern "C" {
472    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfileoperationkinddecompressingafterdownloading?language=objc)
473    #[cfg(feature = "NSString")]
474    pub static NSProgressFileOperationKindDecompressingAfterDownloading:
475        &'static NSProgressFileOperationKind;
476}
477
478extern "C" {
479    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfileoperationkindreceiving?language=objc)
480    #[cfg(feature = "NSString")]
481    pub static NSProgressFileOperationKindReceiving: &'static NSProgressFileOperationKind;
482}
483
484extern "C" {
485    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfileoperationkindcopying?language=objc)
486    #[cfg(feature = "NSString")]
487    pub static NSProgressFileOperationKindCopying: &'static NSProgressFileOperationKind;
488}
489
490extern "C" {
491    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfileoperationkinduploading?language=objc)
492    #[cfg(feature = "NSString")]
493    pub static NSProgressFileOperationKindUploading: &'static NSProgressFileOperationKind;
494}
495
496extern "C" {
497    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfileoperationkindduplicating?language=objc)
498    #[cfg(feature = "NSString")]
499    pub static NSProgressFileOperationKindDuplicating: &'static NSProgressFileOperationKind;
500}
501
502extern "C" {
503    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfileurlkey?language=objc)
504    #[cfg(feature = "NSString")]
505    pub static NSProgressFileURLKey: &'static NSProgressUserInfoKey;
506}
507
508extern "C" {
509    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfiletotalcountkey?language=objc)
510    #[cfg(feature = "NSString")]
511    pub static NSProgressFileTotalCountKey: &'static NSProgressUserInfoKey;
512}
513
514extern "C" {
515    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfilecompletedcountkey?language=objc)
516    #[cfg(feature = "NSString")]
517    pub static NSProgressFileCompletedCountKey: &'static NSProgressUserInfoKey;
518}
519
520extern "C" {
521    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfileanimationimagekey?language=objc)
522    #[cfg(feature = "NSString")]
523    pub static NSProgressFileAnimationImageKey: &'static NSProgressUserInfoKey;
524}
525
526extern "C" {
527    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfileanimationimageoriginalrectkey?language=objc)
528    #[cfg(feature = "NSString")]
529    pub static NSProgressFileAnimationImageOriginalRectKey: &'static NSProgressUserInfoKey;
530}
531
532extern "C" {
533    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsprogressfileiconkey?language=objc)
534    #[cfg(feature = "NSString")]
535    pub static NSProgressFileIconKey: &'static NSProgressUserInfoKey;
536}