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