objc2_ui_kit/generated/
UIDocument.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct UIDocumentChangeKind(pub NSInteger);
15impl UIDocumentChangeKind {
16 #[doc(alias = "UIDocumentChangeDone")]
17 pub const Done: Self = Self(0);
18 #[doc(alias = "UIDocumentChangeUndone")]
19 pub const Undone: Self = Self(1);
20 #[doc(alias = "UIDocumentChangeRedone")]
21 pub const Redone: Self = Self(2);
22 #[doc(alias = "UIDocumentChangeCleared")]
23 pub const Cleared: Self = Self(3);
24}
25
26unsafe impl Encode for UIDocumentChangeKind {
27 const ENCODING: Encoding = NSInteger::ENCODING;
28}
29
30unsafe impl RefEncode for UIDocumentChangeKind {
31 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
32}
33
34#[repr(transparent)]
37#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
38pub struct UIDocumentSaveOperation(pub NSInteger);
39impl UIDocumentSaveOperation {
40 #[doc(alias = "UIDocumentSaveForCreating")]
41 pub const ForCreating: Self = Self(0);
42 #[doc(alias = "UIDocumentSaveForOverwriting")]
43 pub const ForOverwriting: Self = Self(1);
44}
45
46unsafe impl Encode for UIDocumentSaveOperation {
47 const ENCODING: Encoding = NSInteger::ENCODING;
48}
49
50unsafe impl RefEncode for UIDocumentSaveOperation {
51 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
52}
53
54#[repr(transparent)]
57#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
58pub struct UIDocumentState(pub NSUInteger);
59bitflags::bitflags! {
60 impl UIDocumentState: NSUInteger {
61 #[doc(alias = "UIDocumentStateNormal")]
62 const Normal = 0;
63 #[doc(alias = "UIDocumentStateClosed")]
64 const Closed = 1<<0;
65 #[doc(alias = "UIDocumentStateInConflict")]
66 const InConflict = 1<<1;
67 #[doc(alias = "UIDocumentStateSavingError")]
68 const SavingError = 1<<2;
69 #[doc(alias = "UIDocumentStateEditingDisabled")]
70 const EditingDisabled = 1<<3;
71 #[doc(alias = "UIDocumentStateProgressAvailable")]
72 const ProgressAvailable = 1<<4;
73 }
74}
75
76unsafe impl Encode for UIDocumentState {
77 const ENCODING: Encoding = NSUInteger::ENCODING;
78}
79
80unsafe impl RefEncode for UIDocumentState {
81 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
82}
83
84pub type UIDocumentCreationIntent = NSString;
87
88extern "C" {
89 pub static UIDocumentCreationIntentDefault: &'static UIDocumentCreationIntent;
91}
92
93extern "C" {
94 pub static UIDocumentStateChangedNotification: &'static NSNotificationName;
96}
97
98extern_class!(
99 #[unsafe(super(NSObject))]
101 #[thread_kind = MainThreadOnly]
102 #[derive(Debug, PartialEq, Eq, Hash)]
103 pub struct UIDocument;
104);
105
106unsafe impl NSFilePresenter for UIDocument {}
107
108unsafe impl NSObjectProtocol for UIDocument {}
109
110unsafe impl NSProgressReporting for UIDocument {}
111
112impl UIDocument {
113 extern_methods!(
114 #[unsafe(method(initWithFileURL:))]
115 #[unsafe(method_family = init)]
116 pub unsafe fn initWithFileURL(this: Allocated<Self>, url: &NSURL) -> Retained<Self>;
117
118 #[unsafe(method(fileURL))]
119 #[unsafe(method_family = none)]
120 pub unsafe fn fileURL(&self) -> Retained<NSURL>;
121
122 #[unsafe(method(localizedName))]
123 #[unsafe(method_family = none)]
124 pub unsafe fn localizedName(&self) -> Retained<NSString>;
125
126 #[unsafe(method(fileType))]
127 #[unsafe(method_family = none)]
128 pub unsafe fn fileType(&self) -> Option<Retained<NSString>>;
129
130 #[unsafe(method(fileModificationDate))]
131 #[unsafe(method_family = none)]
132 pub unsafe fn fileModificationDate(&self) -> Option<Retained<NSDate>>;
133
134 #[unsafe(method(setFileModificationDate:))]
136 #[unsafe(method_family = none)]
137 pub unsafe fn setFileModificationDate(&self, file_modification_date: Option<&NSDate>);
138
139 #[unsafe(method(documentState))]
140 #[unsafe(method_family = none)]
141 pub unsafe fn documentState(&self) -> UIDocumentState;
142
143 #[unsafe(method(progress))]
144 #[unsafe(method_family = none)]
145 pub unsafe fn progress(&self) -> Option<Retained<NSProgress>>;
146
147 #[cfg(feature = "block2")]
148 #[unsafe(method(openWithCompletionHandler:))]
149 #[unsafe(method_family = none)]
150 pub unsafe fn openWithCompletionHandler(
151 &self,
152 completion_handler: Option<&block2::Block<dyn Fn(Bool)>>,
153 );
154
155 #[cfg(feature = "block2")]
156 #[unsafe(method(closeWithCompletionHandler:))]
157 #[unsafe(method_family = none)]
158 pub unsafe fn closeWithCompletionHandler(
159 &self,
160 completion_handler: Option<&block2::Block<dyn Fn(Bool)>>,
161 );
162
163 #[unsafe(method(loadFromContents:ofType:error:_))]
164 #[unsafe(method_family = none)]
165 pub unsafe fn loadFromContents_ofType_error(
166 &self,
167 contents: &AnyObject,
168 type_name: Option<&NSString>,
169 ) -> Result<(), Retained<NSError>>;
170
171 #[unsafe(method(contentsForType:error:_))]
172 #[unsafe(method_family = none)]
173 pub unsafe fn contentsForType_error(
174 &self,
175 type_name: &NSString,
176 ) -> Result<Retained<AnyObject>, Retained<NSError>>;
177
178 #[unsafe(method(disableEditing))]
179 #[unsafe(method_family = none)]
180 pub unsafe fn disableEditing(&self);
181
182 #[unsafe(method(enableEditing))]
183 #[unsafe(method_family = none)]
184 pub unsafe fn enableEditing(&self);
185
186 #[unsafe(method(undoManager))]
187 #[unsafe(method_family = none)]
188 pub unsafe fn undoManager(&self) -> Option<Retained<NSUndoManager>>;
189
190 #[unsafe(method(setUndoManager:))]
192 #[unsafe(method_family = none)]
193 pub unsafe fn setUndoManager(&self, undo_manager: Option<&NSUndoManager>);
194
195 #[unsafe(method(hasUnsavedChanges))]
196 #[unsafe(method_family = none)]
197 pub unsafe fn hasUnsavedChanges(&self) -> bool;
198
199 #[unsafe(method(updateChangeCount:))]
200 #[unsafe(method_family = none)]
201 pub unsafe fn updateChangeCount(&self, change: UIDocumentChangeKind);
202
203 #[unsafe(method(changeCountTokenForSaveOperation:))]
204 #[unsafe(method_family = none)]
205 pub unsafe fn changeCountTokenForSaveOperation(
206 &self,
207 save_operation: UIDocumentSaveOperation,
208 ) -> Retained<AnyObject>;
209
210 #[unsafe(method(updateChangeCountWithToken:forSaveOperation:))]
211 #[unsafe(method_family = none)]
212 pub unsafe fn updateChangeCountWithToken_forSaveOperation(
213 &self,
214 change_count_token: &AnyObject,
215 save_operation: UIDocumentSaveOperation,
216 );
217
218 #[cfg(feature = "block2")]
219 #[unsafe(method(saveToURL:forSaveOperation:completionHandler:))]
220 #[unsafe(method_family = none)]
221 pub unsafe fn saveToURL_forSaveOperation_completionHandler(
222 &self,
223 url: &NSURL,
224 save_operation: UIDocumentSaveOperation,
225 completion_handler: Option<&block2::Block<dyn Fn(Bool)>>,
226 );
227
228 #[cfg(feature = "block2")]
229 #[unsafe(method(autosaveWithCompletionHandler:))]
230 #[unsafe(method_family = none)]
231 pub unsafe fn autosaveWithCompletionHandler(
232 &self,
233 completion_handler: Option<&block2::Block<dyn Fn(Bool)>>,
234 );
235
236 #[unsafe(method(savingFileType))]
237 #[unsafe(method_family = none)]
238 pub unsafe fn savingFileType(&self) -> Option<Retained<NSString>>;
239
240 #[unsafe(method(fileNameExtensionForType:saveOperation:))]
241 #[unsafe(method_family = none)]
242 pub unsafe fn fileNameExtensionForType_saveOperation(
243 &self,
244 type_name: Option<&NSString>,
245 save_operation: UIDocumentSaveOperation,
246 ) -> Retained<NSString>;
247
248 #[unsafe(method(writeContents:andAttributes:safelyToURL:forSaveOperation:error:_))]
249 #[unsafe(method_family = none)]
250 pub unsafe fn writeContents_andAttributes_safelyToURL_forSaveOperation_error(
251 &self,
252 contents: &AnyObject,
253 additional_file_attributes: Option<&NSDictionary>,
254 url: &NSURL,
255 save_operation: UIDocumentSaveOperation,
256 ) -> Result<(), Retained<NSError>>;
257
258 #[unsafe(method(writeContents:toURL:forSaveOperation:originalContentsURL:error:_))]
259 #[unsafe(method_family = none)]
260 pub unsafe fn writeContents_toURL_forSaveOperation_originalContentsURL_error(
261 &self,
262 contents: &AnyObject,
263 url: &NSURL,
264 save_operation: UIDocumentSaveOperation,
265 original_contents_url: Option<&NSURL>,
266 ) -> Result<(), Retained<NSError>>;
267
268 #[unsafe(method(fileAttributesToWriteToURL:forSaveOperation:error:_))]
269 #[unsafe(method_family = none)]
270 pub unsafe fn fileAttributesToWriteToURL_forSaveOperation_error(
271 &self,
272 url: &NSURL,
273 save_operation: UIDocumentSaveOperation,
274 ) -> Result<Retained<NSDictionary>, Retained<NSError>>;
275
276 #[unsafe(method(readFromURL:error:_))]
277 #[unsafe(method_family = none)]
278 pub unsafe fn readFromURL_error(&self, url: &NSURL) -> Result<(), Retained<NSError>>;
279
280 #[cfg(feature = "block2")]
281 #[unsafe(method(performAsynchronousFileAccessUsingBlock:))]
282 #[unsafe(method_family = none)]
283 pub unsafe fn performAsynchronousFileAccessUsingBlock(
284 &self,
285 block: &block2::Block<dyn Fn()>,
286 );
287
288 #[unsafe(method(handleError:userInteractionPermitted:))]
289 #[unsafe(method_family = none)]
290 pub unsafe fn handleError_userInteractionPermitted(
291 &self,
292 error: &NSError,
293 user_interaction_permitted: bool,
294 );
295
296 #[unsafe(method(finishedHandlingError:recovered:))]
297 #[unsafe(method_family = none)]
298 pub unsafe fn finishedHandlingError_recovered(&self, error: &NSError, recovered: bool);
299
300 #[unsafe(method(userInteractionNoLongerPermittedForError:))]
301 #[unsafe(method_family = none)]
302 pub unsafe fn userInteractionNoLongerPermittedForError(&self, error: &NSError);
303
304 #[cfg(feature = "block2")]
305 #[unsafe(method(revertToContentsOfURL:completionHandler:))]
306 #[unsafe(method_family = none)]
307 pub unsafe fn revertToContentsOfURL_completionHandler(
308 &self,
309 url: &NSURL,
310 completion_handler: Option<&block2::Block<dyn Fn(Bool)>>,
311 );
312 );
313}
314
315impl UIDocument {
317 extern_methods!(
318 #[unsafe(method(init))]
319 #[unsafe(method_family = init)]
320 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
321
322 #[unsafe(method(new))]
323 #[unsafe(method_family = new)]
324 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
325 );
326}
327
328impl UIDocument {
329 extern_methods!();
330}
331
332#[cfg(feature = "UINavigationItem")]
333unsafe impl UINavigationItemRenameDelegate for UIDocument {}
334
335extern "C" {
336 pub static NSUserActivityDocumentURLKey: &'static NSString;
338}
339
340impl UIDocument {
342 extern_methods!(
343 #[unsafe(method(userActivity))]
344 #[unsafe(method_family = none)]
345 pub unsafe fn userActivity(&self) -> Option<Retained<NSUserActivity>>;
346
347 #[unsafe(method(setUserActivity:))]
349 #[unsafe(method_family = none)]
350 pub unsafe fn setUserActivity(&self, user_activity: Option<&NSUserActivity>);
351
352 #[unsafe(method(updateUserActivityState:))]
353 #[unsafe(method_family = none)]
354 pub unsafe fn updateUserActivityState(&self, user_activity: &NSUserActivity);
355
356 #[unsafe(method(restoreUserActivityState:))]
357 #[unsafe(method_family = none)]
358 pub unsafe fn restoreUserActivityState(&self, user_activity: &NSUserActivity);
359 );
360}
361
362#[cfg(feature = "UIUserActivity")]
363unsafe impl UIUserActivityRestoring for UIDocument {}