objc2_ui_kit/generated/
UIDocumentPickerViewController.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::*;
6use objc2_foundation::*;
7#[cfg(feature = "objc2-uniform-type-identifiers")]
8use objc2_uniform_type_identifiers::*;
9
10use crate::*;
11
12extern_protocol!(
13    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uidocumentpickerdelegate?language=objc)
14    pub unsafe trait UIDocumentPickerDelegate: NSObjectProtocol + MainThreadOnly {
15        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
16        #[optional]
17        #[unsafe(method(documentPicker:didPickDocumentsAtURLs:))]
18        #[unsafe(method_family = none)]
19        unsafe fn documentPicker_didPickDocumentsAtURLs(
20            &self,
21            controller: &UIDocumentPickerViewController,
22            urls: &NSArray<NSURL>,
23        );
24
25        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
26        #[optional]
27        #[unsafe(method(documentPickerWasCancelled:))]
28        #[unsafe(method_family = none)]
29        unsafe fn documentPickerWasCancelled(&self, controller: &UIDocumentPickerViewController);
30
31        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
32        #[deprecated]
33        #[optional]
34        #[unsafe(method(documentPicker:didPickDocumentAtURL:))]
35        #[unsafe(method_family = none)]
36        unsafe fn documentPicker_didPickDocumentAtURL(
37            &self,
38            controller: &UIDocumentPickerViewController,
39            url: &NSURL,
40        );
41    }
42);
43
44/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uidocumentpickermode?language=objc)
45// NS_ENUM
46#[deprecated = "Use appropriate initializers instead"]
47#[repr(transparent)]
48#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
49pub struct UIDocumentPickerMode(pub NSUInteger);
50impl UIDocumentPickerMode {
51    #[deprecated = "Use appropriate initializers instead"]
52    #[doc(alias = "UIDocumentPickerModeImport")]
53    pub const Import: Self = Self(0);
54    #[deprecated = "Use appropriate initializers instead"]
55    #[doc(alias = "UIDocumentPickerModeOpen")]
56    pub const Open: Self = Self(1);
57    #[deprecated = "Use appropriate initializers instead"]
58    #[doc(alias = "UIDocumentPickerModeExportToService")]
59    pub const ExportToService: Self = Self(2);
60    #[deprecated = "Use appropriate initializers instead"]
61    #[doc(alias = "UIDocumentPickerModeMoveToService")]
62    pub const MoveToService: Self = Self(3);
63}
64
65unsafe impl Encode for UIDocumentPickerMode {
66    const ENCODING: Encoding = NSUInteger::ENCODING;
67}
68
69unsafe impl RefEncode for UIDocumentPickerMode {
70    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
71}
72
73extern_class!(
74    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uidocumentpickerviewcontroller?language=objc)
75    #[unsafe(super(UIViewController, UIResponder, NSObject))]
76    #[thread_kind = MainThreadOnly]
77    #[derive(Debug, PartialEq, Eq, Hash)]
78    #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
79    pub struct UIDocumentPickerViewController;
80);
81
82#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
83unsafe impl NSCoding for UIDocumentPickerViewController {}
84
85#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
86unsafe impl NSObjectProtocol for UIDocumentPickerViewController {}
87
88#[cfg(all(
89    feature = "UIAppearance",
90    feature = "UIResponder",
91    feature = "UIViewController"
92))]
93unsafe impl UIAppearanceContainer for UIDocumentPickerViewController {}
94
95#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
96unsafe impl UIContentContainer for UIDocumentPickerViewController {}
97
98#[cfg(all(
99    feature = "UIFocus",
100    feature = "UIResponder",
101    feature = "UIViewController"
102))]
103unsafe impl UIFocusEnvironment for UIDocumentPickerViewController {}
104
105#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
106unsafe impl UIResponderStandardEditActions for UIDocumentPickerViewController {}
107
108#[cfg(all(
109    feature = "UIResponder",
110    feature = "UITraitCollection",
111    feature = "UIViewController"
112))]
113unsafe impl UITraitEnvironment for UIDocumentPickerViewController {}
114
115#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
116impl UIDocumentPickerViewController {
117    extern_methods!(
118        #[deprecated]
119        #[unsafe(method(initWithDocumentTypes:inMode:))]
120        #[unsafe(method_family = init)]
121        pub unsafe fn initWithDocumentTypes_inMode(
122            this: Allocated<Self>,
123            allowed_ut_is: &NSArray<NSString>,
124            mode: UIDocumentPickerMode,
125        ) -> Retained<Self>;
126
127        #[cfg(feature = "objc2-uniform-type-identifiers")]
128        /// Initializes the picker instance for selecting a document in a remote location.
129        ///
130        /// Parameter `asCopy`: if true, the picker will give you access to a local copy of the document, otherwise you will have access to the original document
131        #[unsafe(method(initForOpeningContentTypes:asCopy:))]
132        #[unsafe(method_family = init)]
133        pub unsafe fn initForOpeningContentTypes_asCopy(
134            this: Allocated<Self>,
135            content_types: &NSArray<UTType>,
136            as_copy: bool,
137        ) -> Retained<Self>;
138
139        #[cfg(feature = "objc2-uniform-type-identifiers")]
140        /// Initializes the picker instance for selecting a document in a remote location, giving you access to the original document.
141        #[unsafe(method(initForOpeningContentTypes:))]
142        #[unsafe(method_family = init)]
143        pub unsafe fn initForOpeningContentTypes(
144            this: Allocated<Self>,
145            content_types: &NSArray<UTType>,
146        ) -> Retained<Self>;
147
148        #[unsafe(method(initWithCoder:))]
149        #[unsafe(method_family = init)]
150        pub unsafe fn initWithCoder(
151            this: Allocated<Self>,
152            coder: &NSCoder,
153        ) -> Option<Retained<Self>>;
154
155        #[deprecated]
156        #[unsafe(method(initWithURL:inMode:))]
157        #[unsafe(method_family = init)]
158        pub unsafe fn initWithURL_inMode(
159            this: Allocated<Self>,
160            url: &NSURL,
161            mode: UIDocumentPickerMode,
162        ) -> Retained<Self>;
163
164        #[deprecated]
165        #[unsafe(method(initWithURLs:inMode:))]
166        #[unsafe(method_family = init)]
167        pub unsafe fn initWithURLs_inMode(
168            this: Allocated<Self>,
169            urls: &NSArray<NSURL>,
170            mode: UIDocumentPickerMode,
171        ) -> Retained<Self>;
172
173        /// Initializes the picker for exporting local documents to an external location. The new locations will be returned using `didPickDocumentAtURLs:`.
174        ///
175        /// Parameter `asCopy`: if true, a copy will be exported to the destination, otherwise the original document will be moved to the destination. For performance reasons and to avoid copies, we recommend you set `asCopy` to false.
176        #[unsafe(method(initForExportingURLs:asCopy:))]
177        #[unsafe(method_family = init)]
178        pub unsafe fn initForExportingURLs_asCopy(
179            this: Allocated<Self>,
180            urls: &NSArray<NSURL>,
181            as_copy: bool,
182        ) -> Retained<Self>;
183
184        /// Initializes the picker for exporting local documents to an external location. The new locations will be returned using `didPickDocumentAtURLs:`. The original document will be moved to the destination.
185        #[unsafe(method(initForExportingURLs:))]
186        #[unsafe(method_family = init)]
187        pub unsafe fn initForExportingURLs(
188            this: Allocated<Self>,
189            urls: &NSArray<NSURL>,
190        ) -> Retained<Self>;
191
192        #[unsafe(method(delegate))]
193        #[unsafe(method_family = none)]
194        pub unsafe fn delegate(
195            &self,
196        ) -> Option<Retained<ProtocolObject<dyn UIDocumentPickerDelegate>>>;
197
198        /// This is a [weak property][objc2::topics::weak_property].
199        /// Setter for [`delegate`][Self::delegate].
200        #[unsafe(method(setDelegate:))]
201        #[unsafe(method_family = none)]
202        pub unsafe fn setDelegate(
203            &self,
204            delegate: Option<&ProtocolObject<dyn UIDocumentPickerDelegate>>,
205        );
206
207        #[deprecated = "Use appropriate initializers instead"]
208        #[unsafe(method(documentPickerMode))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn documentPickerMode(&self) -> UIDocumentPickerMode;
211
212        #[unsafe(method(allowsMultipleSelection))]
213        #[unsafe(method_family = none)]
214        pub unsafe fn allowsMultipleSelection(&self) -> bool;
215
216        /// Setter for [`allowsMultipleSelection`][Self::allowsMultipleSelection].
217        #[unsafe(method(setAllowsMultipleSelection:))]
218        #[unsafe(method_family = none)]
219        pub unsafe fn setAllowsMultipleSelection(&self, allows_multiple_selection: bool);
220
221        /// Force the display of supported file extensions (default: NO).
222        #[unsafe(method(shouldShowFileExtensions))]
223        #[unsafe(method_family = none)]
224        pub unsafe fn shouldShowFileExtensions(&self) -> bool;
225
226        /// Setter for [`shouldShowFileExtensions`][Self::shouldShowFileExtensions].
227        #[unsafe(method(setShouldShowFileExtensions:))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn setShouldShowFileExtensions(&self, should_show_file_extensions: bool);
230
231        /// Picker will try to display this URL when presented
232        #[unsafe(method(directoryURL))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn directoryURL(&self) -> Option<Retained<NSURL>>;
235
236        /// Setter for [`directoryURL`][Self::directoryURL].
237        #[unsafe(method(setDirectoryURL:))]
238        #[unsafe(method_family = none)]
239        pub unsafe fn setDirectoryURL(&self, directory_url: Option<&NSURL>);
240    );
241}
242
243/// Methods declared on superclass `UIViewController`.
244#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
245impl UIDocumentPickerViewController {
246    extern_methods!(
247        #[unsafe(method(initWithNibName:bundle:))]
248        #[unsafe(method_family = init)]
249        pub unsafe fn initWithNibName_bundle(
250            this: Allocated<Self>,
251            nib_name_or_nil: Option<&NSString>,
252            nib_bundle_or_nil: Option<&NSBundle>,
253        ) -> Retained<Self>;
254    );
255}
256
257/// Methods declared on superclass `NSObject`.
258#[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
259impl UIDocumentPickerViewController {
260    extern_methods!(
261        #[unsafe(method(init))]
262        #[unsafe(method_family = init)]
263        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
264
265        #[unsafe(method(new))]
266        #[unsafe(method_family = new)]
267        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
268    );
269}