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 "C" {
99 pub static UIDocumentDidMoveToWritableLocationNotification: &'static NSNotificationName;
104}
105
106extern "C" {
107 pub static UIDocumentDidMoveToWritableLocationOldURLKey: &'static NSString;
111}
112
113extern_class!(
114 #[unsafe(super(NSObject))]
116 #[thread_kind = MainThreadOnly]
117 #[derive(Debug, PartialEq, Eq, Hash)]
118 pub struct UIDocument;
119);
120
121extern_conformance!(
122 unsafe impl NSFilePresenter for UIDocument {}
123);
124
125extern_conformance!(
126 unsafe impl NSObjectProtocol for UIDocument {}
127);
128
129extern_conformance!(
130 unsafe impl NSProgressReporting for UIDocument {}
131);
132
133impl UIDocument {
134 extern_methods!(
135 #[unsafe(method(initWithFileURL:))]
136 #[unsafe(method_family = init)]
137 pub fn initWithFileURL(this: Allocated<Self>, url: &NSURL) -> Retained<Self>;
138
139 #[unsafe(method(fileURL))]
140 #[unsafe(method_family = none)]
141 pub fn fileURL(&self) -> Retained<NSURL>;
142
143 #[unsafe(method(localizedName))]
144 #[unsafe(method_family = none)]
145 pub fn localizedName(&self) -> Retained<NSString>;
146
147 #[unsafe(method(fileType))]
148 #[unsafe(method_family = none)]
149 pub fn fileType(&self) -> Option<Retained<NSString>>;
150
151 #[unsafe(method(fileModificationDate))]
152 #[unsafe(method_family = none)]
153 pub fn fileModificationDate(&self) -> Option<Retained<NSDate>>;
154
155 #[unsafe(method(setFileModificationDate:))]
159 #[unsafe(method_family = none)]
160 pub fn setFileModificationDate(&self, file_modification_date: Option<&NSDate>);
161
162 #[unsafe(method(documentState))]
163 #[unsafe(method_family = none)]
164 pub fn documentState(&self) -> UIDocumentState;
165
166 #[unsafe(method(progress))]
167 #[unsafe(method_family = none)]
168 pub fn progress(&self) -> Option<Retained<NSProgress>>;
169
170 #[cfg(feature = "block2")]
171 #[unsafe(method(openWithCompletionHandler:))]
172 #[unsafe(method_family = none)]
173 pub fn openWithCompletionHandler(
174 &self,
175 completion_handler: Option<&block2::DynBlock<dyn Fn(Bool)>>,
176 );
177
178 #[cfg(feature = "block2")]
179 #[unsafe(method(closeWithCompletionHandler:))]
180 #[unsafe(method_family = none)]
181 pub fn closeWithCompletionHandler(
182 &self,
183 completion_handler: Option<&block2::DynBlock<dyn Fn(Bool)>>,
184 );
185
186 #[unsafe(method(loadFromContents:ofType:error:_))]
190 #[unsafe(method_family = none)]
191 pub unsafe fn loadFromContents_ofType_error(
192 &self,
193 contents: &AnyObject,
194 type_name: Option<&NSString>,
195 ) -> Result<(), Retained<NSError>>;
196
197 #[unsafe(method(contentsForType:error:_))]
198 #[unsafe(method_family = none)]
199 pub fn contentsForType_error(
200 &self,
201 type_name: &NSString,
202 ) -> Result<Retained<AnyObject>, Retained<NSError>>;
203
204 #[unsafe(method(disableEditing))]
205 #[unsafe(method_family = none)]
206 pub fn disableEditing(&self);
207
208 #[unsafe(method(enableEditing))]
209 #[unsafe(method_family = none)]
210 pub fn enableEditing(&self);
211
212 #[unsafe(method(undoManager))]
213 #[unsafe(method_family = none)]
214 pub fn undoManager(&self) -> Option<Retained<NSUndoManager>>;
215
216 #[unsafe(method(setUndoManager:))]
222 #[unsafe(method_family = none)]
223 pub unsafe fn setUndoManager(&self, undo_manager: Option<&NSUndoManager>);
224
225 #[unsafe(method(hasUnsavedChanges))]
226 #[unsafe(method_family = none)]
227 pub fn hasUnsavedChanges(&self) -> bool;
228
229 #[unsafe(method(updateChangeCount:))]
230 #[unsafe(method_family = none)]
231 pub fn updateChangeCount(&self, change: UIDocumentChangeKind);
232
233 #[unsafe(method(changeCountTokenForSaveOperation:))]
234 #[unsafe(method_family = none)]
235 pub fn changeCountTokenForSaveOperation(
236 &self,
237 save_operation: UIDocumentSaveOperation,
238 ) -> Retained<AnyObject>;
239
240 #[unsafe(method(updateChangeCountWithToken:forSaveOperation:))]
244 #[unsafe(method_family = none)]
245 pub unsafe fn updateChangeCountWithToken_forSaveOperation(
246 &self,
247 change_count_token: &AnyObject,
248 save_operation: UIDocumentSaveOperation,
249 );
250
251 #[cfg(feature = "block2")]
252 #[unsafe(method(saveToURL:forSaveOperation:completionHandler:))]
253 #[unsafe(method_family = none)]
254 pub fn saveToURL_forSaveOperation_completionHandler(
255 &self,
256 url: &NSURL,
257 save_operation: UIDocumentSaveOperation,
258 completion_handler: Option<&block2::DynBlock<dyn Fn(Bool)>>,
259 );
260
261 #[cfg(feature = "block2")]
262 #[unsafe(method(autosaveWithCompletionHandler:))]
263 #[unsafe(method_family = none)]
264 pub fn autosaveWithCompletionHandler(
265 &self,
266 completion_handler: Option<&block2::DynBlock<dyn Fn(Bool)>>,
267 );
268
269 #[unsafe(method(savingFileType))]
270 #[unsafe(method_family = none)]
271 pub fn savingFileType(&self) -> Option<Retained<NSString>>;
272
273 #[unsafe(method(fileNameExtensionForType:saveOperation:))]
274 #[unsafe(method_family = none)]
275 pub fn fileNameExtensionForType_saveOperation(
276 &self,
277 type_name: Option<&NSString>,
278 save_operation: UIDocumentSaveOperation,
279 ) -> Retained<NSString>;
280
281 #[unsafe(method(writeContents:andAttributes:safelyToURL:forSaveOperation:error:_))]
286 #[unsafe(method_family = none)]
287 pub unsafe fn writeContents_andAttributes_safelyToURL_forSaveOperation_error(
288 &self,
289 contents: &AnyObject,
290 additional_file_attributes: Option<&NSDictionary>,
291 url: &NSURL,
292 save_operation: UIDocumentSaveOperation,
293 ) -> Result<(), Retained<NSError>>;
294
295 #[unsafe(method(writeContents:toURL:forSaveOperation:originalContentsURL:error:_))]
299 #[unsafe(method_family = none)]
300 pub unsafe fn writeContents_toURL_forSaveOperation_originalContentsURL_error(
301 &self,
302 contents: &AnyObject,
303 url: &NSURL,
304 save_operation: UIDocumentSaveOperation,
305 original_contents_url: Option<&NSURL>,
306 ) -> Result<(), Retained<NSError>>;
307
308 #[unsafe(method(fileAttributesToWriteToURL:forSaveOperation:error:_))]
309 #[unsafe(method_family = none)]
310 pub fn fileAttributesToWriteToURL_forSaveOperation_error(
311 &self,
312 url: &NSURL,
313 save_operation: UIDocumentSaveOperation,
314 ) -> Result<Retained<NSDictionary>, Retained<NSError>>;
315
316 #[unsafe(method(readFromURL:error:_))]
317 #[unsafe(method_family = none)]
318 pub fn readFromURL_error(&self, url: &NSURL) -> Result<(), Retained<NSError>>;
319
320 #[cfg(feature = "block2")]
321 #[unsafe(method(performAsynchronousFileAccessUsingBlock:))]
322 #[unsafe(method_family = none)]
323 pub fn performAsynchronousFileAccessUsingBlock(&self, block: &block2::DynBlock<dyn Fn()>);
324
325 #[unsafe(method(handleError:userInteractionPermitted:))]
326 #[unsafe(method_family = none)]
327 pub fn handleError_userInteractionPermitted(
328 &self,
329 error: &NSError,
330 user_interaction_permitted: bool,
331 );
332
333 #[unsafe(method(finishedHandlingError:recovered:))]
334 #[unsafe(method_family = none)]
335 pub fn finishedHandlingError_recovered(&self, error: &NSError, recovered: bool);
336
337 #[unsafe(method(userInteractionNoLongerPermittedForError:))]
338 #[unsafe(method_family = none)]
339 pub fn userInteractionNoLongerPermittedForError(&self, error: &NSError);
340
341 #[cfg(feature = "block2")]
342 #[unsafe(method(revertToContentsOfURL:completionHandler:))]
343 #[unsafe(method_family = none)]
344 pub fn revertToContentsOfURL_completionHandler(
345 &self,
346 url: &NSURL,
347 completion_handler: Option<&block2::DynBlock<dyn Fn(Bool)>>,
348 );
349 );
350}
351
352impl UIDocument {
354 extern_methods!(
355 #[unsafe(method(init))]
356 #[unsafe(method_family = init)]
357 pub fn init(this: Allocated<Self>) -> Retained<Self>;
358
359 #[unsafe(method(new))]
360 #[unsafe(method_family = new)]
361 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
362 );
363}
364
365impl UIDocument {
366 extern_methods!();
367}
368
369#[cfg(feature = "UINavigationItem")]
370extern_conformance!(
371 unsafe impl UINavigationItemRenameDelegate for UIDocument {}
372);
373
374extern "C" {
375 pub static NSUserActivityDocumentURLKey: &'static NSString;
377}
378
379impl UIDocument {
381 extern_methods!(
382 #[unsafe(method(userActivity))]
383 #[unsafe(method_family = none)]
384 pub fn userActivity(&self) -> Option<Retained<NSUserActivity>>;
385
386 #[unsafe(method(setUserActivity:))]
388 #[unsafe(method_family = none)]
389 pub fn setUserActivity(&self, user_activity: Option<&NSUserActivity>);
390
391 #[unsafe(method(updateUserActivityState:))]
392 #[unsafe(method_family = none)]
393 pub fn updateUserActivityState(&self, user_activity: &NSUserActivity);
394
395 #[unsafe(method(restoreUserActivityState:))]
396 #[unsafe(method_family = none)]
397 pub fn restoreUserActivityState(&self, user_activity: &NSUserActivity);
398 );
399}
400
401#[cfg(feature = "UIUserActivity")]
402extern_conformance!(
403 unsafe impl UIUserActivityRestoring for UIDocument {}
404);