objc2_file_provider/generated/
NSFileProviderDomain.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
8use crate::*;
9
10/// [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileproviderdomainidentifier?language=objc)
11// NS_TYPED_EXTENSIBLE_ENUM
12pub type NSFileProviderDomainIdentifier = NSString;
13
14extern_class!(
15    /// File provider domain version.
16    ///
17    /// This object can be used by the `NSFileProviderReplicatedExtension` to describe the
18    /// current version of the domain. This object is immutable and can safely be used as
19    /// a key in a dictionary.
20    ///
21    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileproviderdomainversion?language=objc)
22    #[unsafe(super(NSObject))]
23    #[derive(Debug, PartialEq, Eq, Hash)]
24    pub struct NSFileProviderDomainVersion;
25);
26
27unsafe impl NSCoding for NSFileProviderDomainVersion {}
28
29unsafe impl NSObjectProtocol for NSFileProviderDomainVersion {}
30
31unsafe impl NSSecureCoding for NSFileProviderDomainVersion {}
32
33impl NSFileProviderDomainVersion {
34    extern_methods!(
35        /// Build a version that is strictly greater than the receiver.
36        #[unsafe(method(next))]
37        #[unsafe(method_family = none)]
38        pub unsafe fn next(&self) -> Retained<NSFileProviderDomainVersion>;
39
40        /// Compare two domain versions.
41        ///
42        /// This returns the NSComparisonResult of the comparison of the receiver and the
43        /// other version:
44        /// - NSOrderedAscending if the receiver predates the otherVersion
45        /// - NSOrderedDescending if the otherVersion predates the receiver
46        /// - NSOrderedSame if both versions are equal
47        ///
48        /// In Swift, NSFileProviderDomainVersion is comparable.
49        #[unsafe(method(compare:))]
50        #[unsafe(method_family = none)]
51        pub unsafe fn compare(
52            &self,
53            other_version: &NSFileProviderDomainVersion,
54        ) -> NSComparisonResult;
55    );
56}
57
58/// Methods declared on superclass `NSObject`.
59impl NSFileProviderDomainVersion {
60    extern_methods!(
61        #[unsafe(method(init))]
62        #[unsafe(method_family = init)]
63        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
64
65        #[unsafe(method(new))]
66        #[unsafe(method_family = new)]
67        pub unsafe fn new() -> Retained<Self>;
68    );
69}
70
71/// Testing modes.
72///
73/// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileproviderdomaintestingmodes?language=objc)
74// NS_OPTIONS
75#[repr(transparent)]
76#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
77pub struct NSFileProviderDomainTestingModes(pub NSUInteger);
78bitflags::bitflags! {
79    impl NSFileProviderDomainTestingModes: NSUInteger {
80/// Enable the domain without any user action required.
81        #[doc(alias = "NSFileProviderDomainTestingModeAlwaysEnabled")]
82        const AlwaysEnabled = 1<<0;
83/// Enable interactive mode.
84///
85/// Disable the automatic scheduling from the system and allow external tools to
86/// control the execution of operations.
87///
88/// When manual scheduling is enabled, an external tool should use
89/// -[NSFileProviderManager listAvailableTestingOperationsWithError:] and
90/// -[NSFileProviderManager runTestingOperations:error:] to control the system.
91///
92/// If that mode is enabled, some crash recovery guarantees are lost. For instance,
93/// the system may lose any event that hasn't been ingested. The system does not
94/// support removing this mode from a domain on which it has been enabled.
95        #[doc(alias = "NSFileProviderDomainTestingModeInteractive")]
96        const Interactive = 1<<1;
97    }
98}
99
100unsafe impl Encode for NSFileProviderDomainTestingModes {
101    const ENCODING: Encoding = NSUInteger::ENCODING;
102}
103
104unsafe impl RefEncode for NSFileProviderDomainTestingModes {
105    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
106}
107
108/// Specifying a list of known folders.
109///
110/// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileproviderknownfolders?language=objc)
111// NS_OPTIONS
112#[repr(transparent)]
113#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
114pub struct NSFileProviderKnownFolders(pub NSUInteger);
115bitflags::bitflags! {
116    impl NSFileProviderKnownFolders: NSUInteger {
117        #[doc(alias = "NSFileProviderDesktop")]
118        const Desktop = 1<<0;
119        #[doc(alias = "NSFileProviderDocuments")]
120        const Documents = 1<<1;
121    }
122}
123
124unsafe impl Encode for NSFileProviderKnownFolders {
125    const ENCODING: Encoding = NSUInteger::ENCODING;
126}
127
128unsafe impl RefEncode for NSFileProviderKnownFolders {
129    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
130}
131
132extern_class!(
133    /// File provider domain.
134    ///
135    /// A file provider domain can be used to represent accounts or different locations
136    /// exposed within a given file provider.
137    ///
138    /// Domains can be registered to the system using
139    /// `-[NSFileProviderMananger`addDomain:completionHandler:]
140    ///
141    /// By default, a file provider extension does not have any domain.
142    ///
143    /// On the extension side, a separate instance of NSFileProviderExtension will be
144    /// created for each
145    /// `NSFileProviderDomain`registered.  In that case, the
146    /// `NSFileProviderExtension.domain`properties will indicate which domain the
147    /// NSFileProviderExtension belongs to (or nil if none).
148    ///
149    /// All the files on disk belonging to the same domain must be grouped inside a
150    /// common directory. That directory path is indicated by the
151    /// `pathRelativeToDocumentStorage`property.
152    ///
153    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileproviderdomain?language=objc)
154    #[unsafe(super(NSObject))]
155    #[derive(Debug, PartialEq, Eq, Hash)]
156    pub struct NSFileProviderDomain;
157);
158
159unsafe impl NSObjectProtocol for NSFileProviderDomain {}
160
161impl NSFileProviderDomain {
162    extern_methods!(
163        /// Initialize a new non-replicated NSFileProviderDomain
164        ///
165        /// The extension will be implementing NSFileProviderExtension.
166        ///
167        /// The file provider extension implementation can pick any
168        /// `identifier`as it sees
169        /// fit to identify the group of items. The identifier must not contain any characters from this set: [/:]
170        ///
171        ///
172        /// Parameter `displayName`: a user visible string representing the group of items the
173        /// file provider extension is using.
174        ///
175        ///
176        /// Parameter `pathRelativeToDocumentStorage`: a path relative to
177        /// `NSFileProviderExtension.documentStorageURL.`
178        #[unsafe(method(initWithIdentifier:displayName:pathRelativeToDocumentStorage:))]
179        #[unsafe(method_family = init)]
180        pub unsafe fn initWithIdentifier_displayName_pathRelativeToDocumentStorage(
181            this: Allocated<Self>,
182            identifier: &NSFileProviderDomainIdentifier,
183            display_name: &NSString,
184            path_relative_to_document_storage: &NSString,
185        ) -> Retained<Self>;
186
187        /// Initialize a new replicated NSFileProviderDomain
188        ///
189        /// The extension will be implementing NSFileProviderReplicatedExtension.
190        ///
191        /// The file provider extension implementation can pick any
192        /// `identifier`as it sees
193        /// fit to identify the group of items. The identifier must not contain any characters from this set: [/:]
194        ///
195        /// In order to migrate a non-replicated domain to a replicated one, implementers have to make sure that they do not
196        /// use the default domain, and then call +[NSFileProviderManager addDomain:completionHandler:] using
197        /// the NSFileProviderDomain object returned by that init method.
198        ///
199        /// A domain with a specific identifier can be added multiple times; subsequent adds will update the properties
200        /// of the existing domain.
201        /// If a replicated domain is added "on top" of a non-replicated domain, the domain will be migrated to be replicated;
202        /// existing bookmarks will remain valid, but the (externally visible) location of items will change to reflect the replicated location.
203        ///
204        /// It is not possible to migrate the default domain in this manner (since the default domain can not be added).
205        /// It is recommended to migrate usage of the default domain to a domain with an explicit identifier instead.
206        ///
207        ///
208        /// Parameter `displayName`: a user visible string representing the group of items the
209        /// file provider extension is using.
210        #[unsafe(method(initWithIdentifier:displayName:))]
211        #[unsafe(method_family = init)]
212        pub unsafe fn initWithIdentifier_displayName(
213            this: Allocated<Self>,
214            identifier: &NSFileProviderDomainIdentifier,
215            display_name: &NSString,
216        ) -> Retained<Self>;
217
218        /// Initialize a new replicated NSFileProviderDomain on a specific volume.
219        ///
220        /// If a volumeURL is specified, and that volume is eligible, the domain will be located on this volume. The URL is used to designate a volume
221        /// but doesn't influence where on this volume is the domain going to be stored.
222        ///
223        /// In order to avoid domainID collisions between volumes, the NSFileProviderDomainIdentifier of external domains are generated randomly by FileProvider.
224        /// The provider should therefore use the userInfo to associate all necessary information to map the created object to the corresponding account.
225        /// The userInfo will be persisted on the volume where the domain was created. If that is an external volume, the userInfo can be used on other devices
226        /// to assist in setting up the domain on those devices. See the`NSFileProviderExternalVolumeHandling` protocol for more details.
227        #[unsafe(method(initWithDisplayName:userInfo:volumeURL:))]
228        #[unsafe(method_family = init)]
229        pub unsafe fn initWithDisplayName_userInfo_volumeURL(
230            this: Allocated<Self>,
231            display_name: &NSString,
232            user_info: &NSDictionary,
233            volume_url: Option<&NSURL>,
234        ) -> Retained<Self>;
235
236        /// The identifier - as provided by the file provider extension.
237        #[unsafe(method(identifier))]
238        #[unsafe(method_family = none)]
239        pub unsafe fn identifier(&self) -> Retained<NSFileProviderDomainIdentifier>;
240
241        /// The display name shown by the system to represent this domain.
242        #[unsafe(method(displayName))]
243        #[unsafe(method_family = none)]
244        pub unsafe fn displayName(&self) -> Retained<NSString>;
245
246        /// The path relative to the document storage of the file provider extension.
247        /// Files belonging to this domains should be stored under this path.
248        #[unsafe(method(pathRelativeToDocumentStorage))]
249        #[unsafe(method_family = none)]
250        pub unsafe fn pathRelativeToDocumentStorage(&self) -> Retained<NSString>;
251
252        /// If set, the domain is present, but disconnected from its extension.
253        /// In this state, the user continues to be able to browse the domain's contents,
254        /// but the extension doesn't receive updates on modifications to the files, nor is
255        /// it consulted to update folder's contents.
256        ///
257        /// The disconnected state can be modified on an existing domain via the disconnectWithReason method
258        /// on NSFileProviderManager.
259        #[unsafe(method(isDisconnected))]
260        #[unsafe(method_family = none)]
261        pub unsafe fn isDisconnected(&self) -> bool;
262
263        /// If user has disabled this domain from Files.app on iOS or System Settings on macOS, this will be set
264        /// to NO.
265        #[unsafe(method(userEnabled))]
266        #[unsafe(method_family = none)]
267        pub unsafe fn userEnabled(&self) -> bool;
268
269        /// If this domain is not user visible.
270        ///
271        /// Typically, this can be used for dry-run migration. The files are still on disk though.
272        #[unsafe(method(isHidden))]
273        #[unsafe(method_family = none)]
274        pub unsafe fn isHidden(&self) -> bool;
275
276        /// Setter for [`isHidden`][Self::isHidden].
277        #[unsafe(method(setHidden:))]
278        #[unsafe(method_family = none)]
279        pub unsafe fn setHidden(&self, hidden: bool);
280
281        /// If the domain is a replicated domain.
282        ///
283        /// If set to YES, it means the domain is replicated. By default, on macOS, the value will always be YES.
284        ///
285        /// On iOS, it will depend on the way the NSFileProviderDomain object is contructed. Calling
286        /// -[NSFileProviderDomain initWithIdentifier:displayName:] will initialize a replicated domain.
287        /// -[NSFileProviderDomain initWithIdentifier:displayName:pathRelativeToDocumentStorage:] will
288        /// initialize a non-replicated domain.
289        ///
290        /// To know whether a domain is replicated or not, users are advised to rely on the output of
291        /// +[NSFileProviderManager getDomainsForProviderIdentifier:completionHandler:]
292        #[unsafe(method(isReplicated))]
293        #[unsafe(method_family = none)]
294        pub unsafe fn isReplicated(&self) -> bool;
295
296        /// Testing modes.
297        ///
298        /// Testing modes are exposed as a means for the provider to have more control over the system in
299        /// a testing environment. Enabling a testing mode alters the behavior of the system and enables
300        /// some APIs for that mode.
301        ///
302        /// A process must have the com.apple.developer.fileprovider.testing-mode entitlement in order to
303        /// configure a domain with non-empty testing modes.
304        #[unsafe(method(testingModes))]
305        #[unsafe(method_family = none)]
306        pub unsafe fn testingModes(&self) -> NSFileProviderDomainTestingModes;
307
308        /// Setter for [`testingModes`][Self::testingModes].
309        #[unsafe(method(setTestingModes:))]
310        #[unsafe(method_family = none)]
311        pub unsafe fn setTestingModes(&self, testing_modes: NSFileProviderDomainTestingModes);
312
313        /// Identity of the backing store of the domain on the system.
314        ///
315        /// This property only applies for extensions that implement NSFileProviderReplicatedExtension.
316        ///
317        /// This provides an identifier that uniquely identifies the backing store used by the system for
318        /// the domain. When this identifier has changed, the system has dropped its backing store and is
319        /// building a new one.
320        ///
321        /// The system may decide to rebuild its backing store if it got corrupted. The backing store can also
322        /// be rebuilt as a response to the provider calling `-[NSFileProviderManager reimportItemsBelowItemWithIdentifier:completionHandler:]`.
323        /// It is guaranteed that calling reimport on the root item will cause the backing store to be rebuilt,
324        /// but the system can also decide to do so when reimport is called on other items.
325        ///
326        /// When rebuilding the backing store, the system will invalidate any extension instance associated
327        /// to that domain. As a consequence, the identity of the backing store associated with that domain
328        /// is guaranteed to be stable for the lifetime of the NSFileProviderReplicatedExtension instance.
329        #[unsafe(method(backingStoreIdentity))]
330        #[unsafe(method_family = none)]
331        pub unsafe fn backingStoreIdentity(&self) -> Option<Retained<NSData>>;
332
333        /// Whether the domain supports syncing the trash.
334        ///
335        /// The system supports syncing a trash folder (NSFileProviderTrashContainerItemIdentifier) to the extension.
336        /// On iOS, this is surfaced to the user as "Recently Deleted" in the Files app. On macOS, this is surfaced
337        /// to the user as the Trash in Finder.
338        ///
339        /// If the domain is configured with supportsSyncingTrash=YES, the system will reparent trashed
340        /// files (which were located in the extension's domain) to NSFileProviderTrashContainerItemIdentifier.
341        /// If the domain is configured with supportsSyncingTrash=NO, the system will decide how to handle
342        /// the trashing operation (not guaranteed by API contract).
343        ///
344        /// This property is only applicable for NSFileProviderReplicatedExtension-based domains.
345        ///
346        /// This property defaults to YES.
347        #[unsafe(method(supportsSyncingTrash))]
348        #[unsafe(method_family = none)]
349        pub unsafe fn supportsSyncingTrash(&self) -> bool;
350
351        /// Setter for [`supportsSyncingTrash`][Self::supportsSyncingTrash].
352        #[unsafe(method(setSupportsSyncingTrash:))]
353        #[unsafe(method_family = none)]
354        pub unsafe fn setSupportsSyncingTrash(&self, supports_syncing_trash: bool);
355
356        #[unsafe(method(volumeUUID))]
357        #[unsafe(method_family = none)]
358        pub unsafe fn volumeUUID(&self) -> Option<Retained<NSUUID>>;
359
360        /// A dictionary set by the client app. Keys must be strings, values must be [String, Number, Date, Data]
361        #[unsafe(method(userInfo))]
362        #[unsafe(method_family = none)]
363        pub unsafe fn userInfo(&self) -> Option<Retained<NSDictionary>>;
364
365        /// Setter for [`userInfo`][Self::userInfo].
366        #[unsafe(method(setUserInfo:))]
367        #[unsafe(method_family = none)]
368        pub unsafe fn setUserInfo(&self, user_info: Option<&NSDictionary>);
369
370        /// List of known folders that are currently replicated by this domain.
371        #[unsafe(method(replicatedKnownFolders))]
372        #[unsafe(method_family = none)]
373        pub unsafe fn replicatedKnownFolders(&self) -> NSFileProviderKnownFolders;
374
375        /// List known folders that can be replicated by this domain.
376        #[unsafe(method(supportedKnownFolders))]
377        #[unsafe(method_family = none)]
378        pub unsafe fn supportedKnownFolders(&self) -> NSFileProviderKnownFolders;
379
380        /// Setter for [`supportedKnownFolders`][Self::supportedKnownFolders].
381        #[unsafe(method(setSupportedKnownFolders:))]
382        #[unsafe(method_family = none)]
383        pub unsafe fn setSupportedKnownFolders(
384            &self,
385            supported_known_folders: NSFileProviderKnownFolders,
386        );
387    );
388}
389
390/// Methods declared on superclass `NSObject`.
391impl NSFileProviderDomain {
392    extern_methods!(
393        #[unsafe(method(init))]
394        #[unsafe(method_family = init)]
395        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
396
397        #[unsafe(method(new))]
398        #[unsafe(method_family = new)]
399        pub unsafe fn new() -> Retained<Self>;
400    );
401}
402
403/// NSFileProviderDomain.
404#[cfg(feature = "Extension")]
405impl NSFileProviderExtension {
406    extern_methods!(
407        #[unsafe(method(domain))]
408        #[unsafe(method_family = none)]
409        pub unsafe fn domain(&self) -> Option<Retained<NSFileProviderDomain>>;
410    );
411}
412
413extern "C" {
414    /// Posted when any domain changed.
415    ///
416    /// Interested client should then call `+[NSFileProviderManager getDomainsWithCompletionHandler:]` and see
417    /// what changed.
418    ///
419    /// Note, this notification starts to be posted only after `+[NSFileProviderManager getDomainsWithCompletionHandler:]` is
420    /// called.
421    ///
422    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileproviderdomaindidchange?language=objc)
423    pub static NSFileProviderDomainDidChange: &'static NSNotificationName;
424}