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