objc2_file_provider/generated/
NSFileProviderTesting.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9/// Type of the operation
10///
11/// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingoperationtype?language=objc)
12// NS_ENUM
13#[repr(transparent)]
14#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
15pub struct NSFileProviderTestingOperationType(pub NSInteger);
16impl NSFileProviderTestingOperationType {
17    #[doc(alias = "NSFileProviderTestingOperationTypeIngestion")]
18    pub const Ingestion: Self = Self(0);
19    #[doc(alias = "NSFileProviderTestingOperationTypeLookup")]
20    pub const Lookup: Self = Self(1);
21    #[doc(alias = "NSFileProviderTestingOperationTypeCreation")]
22    pub const Creation: Self = Self(2);
23    #[doc(alias = "NSFileProviderTestingOperationTypeModification")]
24    pub const Modification: Self = Self(3);
25    #[doc(alias = "NSFileProviderTestingOperationTypeDeletion")]
26    pub const Deletion: Self = Self(4);
27    #[doc(alias = "NSFileProviderTestingOperationTypeContentFetch")]
28    pub const ContentFetch: Self = Self(5);
29    #[doc(alias = "NSFileProviderTestingOperationTypeChildrenEnumeration")]
30    pub const ChildrenEnumeration: Self = Self(6);
31    #[doc(alias = "NSFileProviderTestingOperationTypeCollisionResolution")]
32    pub const CollisionResolution: Self = Self(7);
33}
34
35unsafe impl Encode for NSFileProviderTestingOperationType {
36    const ENCODING: Encoding = NSInteger::ENCODING;
37}
38
39unsafe impl RefEncode for NSFileProviderTestingOperationType {
40    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
41}
42
43extern_protocol!(
44    /// An operation that can scheduled.
45    ///
46    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingoperation?language=objc)
47    pub unsafe trait NSFileProviderTestingOperation: NSObjectProtocol {
48        /// The operation type
49        #[unsafe(method(type))]
50        #[unsafe(method_family = none)]
51        unsafe fn r#type(&self) -> NSFileProviderTestingOperationType;
52
53        /// Returns the operation as an Ingestion.
54        ///
55        /// Returns the operation if it conforms to NSFileProviderTestingIngestion, otherwise returns nil.
56        #[unsafe(method(asIngestion))]
57        #[unsafe(method_family = none)]
58        unsafe fn asIngestion(
59            &self,
60        ) -> Option<Retained<ProtocolObject<dyn NSFileProviderTestingIngestion>>>;
61
62        /// Returns the operation as an Lookup.
63        ///
64        /// Returns the operation if it conforms to NSFileProviderTestingLookup, otherwise returns nil.
65        #[unsafe(method(asLookup))]
66        #[unsafe(method_family = none)]
67        unsafe fn asLookup(
68            &self,
69        ) -> Option<Retained<ProtocolObject<dyn NSFileProviderTestingLookup>>>;
70
71        /// Returns the operation as an Creation.
72        ///
73        /// Returns the operation if it conforms to NSFileProviderTestingCreation, otherwise returns nil.
74        #[unsafe(method(asCreation))]
75        #[unsafe(method_family = none)]
76        unsafe fn asCreation(
77            &self,
78        ) -> Option<Retained<ProtocolObject<dyn NSFileProviderTestingCreation>>>;
79
80        /// Returns the operation as an Modification.
81        ///
82        /// Returns the operation if it conforms to NSFileProviderTestingModification, otherwise returns nil.
83        #[unsafe(method(asModification))]
84        #[unsafe(method_family = none)]
85        unsafe fn asModification(
86            &self,
87        ) -> Option<Retained<ProtocolObject<dyn NSFileProviderTestingModification>>>;
88
89        /// Returns the operation as an Deletion.
90        ///
91        /// Returns the operation if it conforms to NSFileProviderTestingDeletion, otherwise returns nil.
92        #[unsafe(method(asDeletion))]
93        #[unsafe(method_family = none)]
94        unsafe fn asDeletion(
95            &self,
96        ) -> Option<Retained<ProtocolObject<dyn NSFileProviderTestingDeletion>>>;
97
98        /// Returns the operation as an ContentFetch.
99        ///
100        /// Returns the operation if it conforms to NSFileProviderTestingContentFetch, otherwise returns nil.
101        #[unsafe(method(asContentFetch))]
102        #[unsafe(method_family = none)]
103        unsafe fn asContentFetch(
104            &self,
105        ) -> Option<Retained<ProtocolObject<dyn NSFileProviderTestingContentFetch>>>;
106
107        /// Returns the operation as an ChildrenEnumeration.
108        ///
109        /// Returns the operation if it conforms to NSFileProviderTestingChildrenEnumeration, otherwise returns nil.
110        #[unsafe(method(asChildrenEnumeration))]
111        #[unsafe(method_family = none)]
112        unsafe fn asChildrenEnumeration(
113            &self,
114        ) -> Option<Retained<ProtocolObject<dyn NSFileProviderTestingChildrenEnumeration>>>;
115
116        /// Returns the operation as an Bounce.
117        ///
118        /// Returns the operation if it conforms to NSFileProviderTestingCollisionResolution, otherwise returns nil.
119        #[unsafe(method(asCollisionResolution))]
120        #[unsafe(method_family = none)]
121        unsafe fn asCollisionResolution(
122            &self,
123        ) -> Option<Retained<ProtocolObject<dyn NSFileProviderTestingCollisionResolution>>>;
124    }
125);
126
127/// TestingModeInteractive.
128///
129/// Control the scheduling of operation.
130///
131/// These methods are available on domain with the NSFileProviderDomainTestingModeInteractive
132/// enabled.
133///
134/// In order to manually schedule the operation, the testing harness will first call
135/// -listAvailableTestingOperationWithError and get a list of operations that can be scheduled.
136/// It can pick one or more operations from that list and call -runTestingOperations:error: to
137/// schedule those operations.
138///
139/// From that point, it should get the new list of available operations and iterate between listing,
140/// picking operation, running those operation and so on.
141///
142/// A process must have the com.apple.developer.fileprovider.testing-mode entitlement in order to
143/// call the methods from this category.
144#[cfg(feature = "Extension")]
145impl NSFileProviderManager {
146    extern_methods!(
147        /// List the available operations.
148        ///
149        /// This lists all of the operations that are ready to be scheduled by the system. The system waits
150        /// for all the pending disk and working set updates to be known before returning.
151        ///
152        /// The operations that are returned may become invalid if the system receives new disk or working
153        /// set events, or if some operation are scheduled using -runTestingOperations:error:.
154        #[unsafe(method(listAvailableTestingOperationsWithError:_))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn listAvailableTestingOperationsWithError(
157            &self,
158        ) -> Result<
159            Retained<NSArray<ProtocolObject<dyn NSFileProviderTestingOperation>>>,
160            Retained<NSError>,
161        >;
162
163        /// Run a set of operations.
164        ///
165        /// Ask the system to schedule the execution of the listed operations. The system will wait until all
166        /// those operations have completed and report a per-operation error in case an operation fails.
167        #[unsafe(method(runTestingOperations:error:_))]
168        #[unsafe(method_family = none)]
169        pub unsafe fn runTestingOperations_error(
170            &self,
171            operations: &NSArray<ProtocolObject<dyn NSFileProviderTestingOperation>>,
172        ) -> Result<
173            Retained<NSDictionary<ProtocolObject<dyn NSFileProviderTestingOperation>, NSError>>,
174            Retained<NSError>,
175        >;
176    );
177}
178
179/// Side affected by the operation.
180///
181/// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingoperationside?language=objc)
182// NS_ENUM
183#[repr(transparent)]
184#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
185pub struct NSFileProviderTestingOperationSide(pub NSUInteger);
186impl NSFileProviderTestingOperationSide {
187    /// The operation reads or writes the disk.
188    #[doc(alias = "NSFileProviderTestingOperationSideDisk")]
189    pub const Disk: Self = Self(0);
190    /// The operation reads or writes the file provider extension.
191    #[doc(alias = "NSFileProviderTestingOperationSideFileProvider")]
192    pub const FileProvider: Self = Self(1);
193}
194
195unsafe impl Encode for NSFileProviderTestingOperationSide {
196    const ENCODING: Encoding = NSUInteger::ENCODING;
197}
198
199unsafe impl RefEncode for NSFileProviderTestingOperationSide {
200    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
201}
202
203extern_protocol!(
204    /// This operation causes the system to ingest a change.
205    ///
206    /// When running this operation, the system will discover a change from the disk or the provider.
207    ///
208    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingingestion?language=objc)
209    pub unsafe trait NSFileProviderTestingIngestion: NSFileProviderTestingOperation {
210        /// Side of the event.
211        #[unsafe(method(side))]
212        #[unsafe(method_family = none)]
213        unsafe fn side(&self) -> NSFileProviderTestingOperationSide;
214
215        #[cfg(feature = "NSFileProviderItem")]
216        /// Identifier of the affected item.
217        #[unsafe(method(itemIdentifier))]
218        #[unsafe(method_family = none)]
219        unsafe fn itemIdentifier(&self) -> Retained<NSFileProviderItemIdentifier>;
220
221        #[cfg(feature = "NSFileProviderItem")]
222        /// The metadata of the item.
223        ///
224        /// This will be nil if the item is being deleted.
225        #[unsafe(method(item))]
226        #[unsafe(method_family = none)]
227        unsafe fn item(&self) -> Option<Retained<NSFileProviderItem>>;
228    }
229);
230
231extern_protocol!(
232    /// This operation causes the system to lookup an item.
233    ///
234    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestinglookup?language=objc)
235    pub unsafe trait NSFileProviderTestingLookup: NSFileProviderTestingOperation {
236        /// Side of the event.
237        #[unsafe(method(side))]
238        #[unsafe(method_family = none)]
239        unsafe fn side(&self) -> NSFileProviderTestingOperationSide;
240
241        #[cfg(feature = "NSFileProviderItem")]
242        /// Identifier of the affected item.
243        #[unsafe(method(itemIdentifier))]
244        #[unsafe(method_family = none)]
245        unsafe fn itemIdentifier(&self) -> Retained<NSFileProviderItemIdentifier>;
246    }
247);
248
249extern_protocol!(
250    /// This operation causes the system to propagate a creation of an item from a source side to a target side.
251    ///
252    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingcreation?language=objc)
253    pub unsafe trait NSFileProviderTestingCreation: NSFileProviderTestingOperation {
254        /// The target side of the operation.
255        #[unsafe(method(targetSide))]
256        #[unsafe(method_family = none)]
257        unsafe fn targetSide(&self) -> NSFileProviderTestingOperationSide;
258
259        #[cfg(feature = "NSFileProviderItem")]
260        /// The description of the item.
261        #[unsafe(method(sourceItem))]
262        #[unsafe(method_family = none)]
263        unsafe fn sourceItem(&self) -> Retained<NSFileProviderItem>;
264
265        #[cfg(feature = "NSFileProviderDomain")]
266        /// The domain version at the time the creation was discovered on the source side.
267        #[unsafe(method(domainVersion))]
268        #[unsafe(method_family = none)]
269        unsafe fn domainVersion(&self) -> Option<Retained<NSFileProviderDomainVersion>>;
270    }
271);
272
273extern_protocol!(
274    /// This operation causes the system to propagate a modification of an existing item from a source side to a target side.
275    ///
276    /// The modification happens if a change is identified on an item that is already known by both sides.
277    ///
278    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingmodification?language=objc)
279    pub unsafe trait NSFileProviderTestingModification:
280        NSFileProviderTestingOperation
281    {
282        /// The target side of the operation.
283        #[unsafe(method(targetSide))]
284        #[unsafe(method_family = none)]
285        unsafe fn targetSide(&self) -> NSFileProviderTestingOperationSide;
286
287        #[cfg(feature = "NSFileProviderItem")]
288        /// The description of the item.
289        #[unsafe(method(sourceItem))]
290        #[unsafe(method_family = none)]
291        unsafe fn sourceItem(&self) -> Retained<NSFileProviderItem>;
292
293        #[cfg(feature = "NSFileProviderItem")]
294        /// The identifier of the target item.
295        #[unsafe(method(targetItemIdentifier))]
296        #[unsafe(method_family = none)]
297        unsafe fn targetItemIdentifier(&self) -> Retained<NSFileProviderItemIdentifier>;
298
299        #[cfg(feature = "NSFileProviderItem")]
300        /// The version of the target item on top of which the modification is applied
301        #[unsafe(method(targetItemBaseVersion))]
302        #[unsafe(method_family = none)]
303        unsafe fn targetItemBaseVersion(&self) -> Retained<NSFileProviderItemVersion>;
304
305        #[cfg(feature = "NSFileProviderItem")]
306        /// The list of updated fields.
307        #[unsafe(method(changedFields))]
308        #[unsafe(method_family = none)]
309        unsafe fn changedFields(&self) -> NSFileProviderItemFields;
310
311        #[cfg(feature = "NSFileProviderDomain")]
312        /// The domain version at the time the change was discovered on the source side.
313        #[unsafe(method(domainVersion))]
314        #[unsafe(method_family = none)]
315        unsafe fn domainVersion(&self) -> Option<Retained<NSFileProviderDomainVersion>>;
316    }
317);
318
319extern_protocol!(
320    /// This operation causes the system to propagate a deletion from a source side to a target side.
321    ///
322    /// The deletion happens if an item that is known by the target side is deleted on the source side.
323    ///
324    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingdeletion?language=objc)
325    pub unsafe trait NSFileProviderTestingDeletion: NSFileProviderTestingOperation {
326        /// The target side of the operation.
327        #[unsafe(method(targetSide))]
328        #[unsafe(method_family = none)]
329        unsafe fn targetSide(&self) -> NSFileProviderTestingOperationSide;
330
331        #[cfg(feature = "NSFileProviderItem")]
332        /// The identifier of the source item.
333        #[unsafe(method(sourceItemIdentifier))]
334        #[unsafe(method_family = none)]
335        unsafe fn sourceItemIdentifier(&self) -> Retained<NSFileProviderItemIdentifier>;
336
337        #[cfg(feature = "NSFileProviderItem")]
338        /// The identifier of the target item.
339        #[unsafe(method(targetItemIdentifier))]
340        #[unsafe(method_family = none)]
341        unsafe fn targetItemIdentifier(&self) -> Retained<NSFileProviderItemIdentifier>;
342
343        #[cfg(feature = "NSFileProviderItem")]
344        /// The version of the target item on top of which the deletion is applied
345        #[unsafe(method(targetItemBaseVersion))]
346        #[unsafe(method_family = none)]
347        unsafe fn targetItemBaseVersion(&self) -> Retained<NSFileProviderItemVersion>;
348
349        #[cfg(feature = "NSFileProviderDomain")]
350        /// The domain version at the time the change was discovered on the source side.
351        #[unsafe(method(domainVersion))]
352        #[unsafe(method_family = none)]
353        unsafe fn domainVersion(&self) -> Option<Retained<NSFileProviderDomainVersion>>;
354    }
355);
356
357extern_protocol!(
358    /// This operation causes the system to fetch the content of an item.
359    ///
360    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingcontentfetch?language=objc)
361    pub unsafe trait NSFileProviderTestingContentFetch:
362        NSFileProviderTestingOperation
363    {
364        /// The side of the operation.
365        #[unsafe(method(side))]
366        #[unsafe(method_family = none)]
367        unsafe fn side(&self) -> NSFileProviderTestingOperationSide;
368
369        #[cfg(feature = "NSFileProviderItem")]
370        /// The identifier of the item.
371        #[unsafe(method(itemIdentifier))]
372        #[unsafe(method_family = none)]
373        unsafe fn itemIdentifier(&self) -> Retained<NSFileProviderItemIdentifier>;
374    }
375);
376
377extern_protocol!(
378    /// This operation causes the system to list the children of an item
379    ///
380    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingchildrenenumeration?language=objc)
381    pub unsafe trait NSFileProviderTestingChildrenEnumeration:
382        NSFileProviderTestingOperation
383    {
384        /// The side of the operation.
385        #[unsafe(method(side))]
386        #[unsafe(method_family = none)]
387        unsafe fn side(&self) -> NSFileProviderTestingOperationSide;
388
389        #[cfg(feature = "NSFileProviderItem")]
390        /// The identifier of the item.
391        #[unsafe(method(itemIdentifier))]
392        #[unsafe(method_family = none)]
393        unsafe fn itemIdentifier(&self) -> Retained<NSFileProviderItemIdentifier>;
394    }
395);
396
397extern_protocol!(
398    /// This operation causes the system to resolve a collision by rename a colliding item.
399    ///
400    /// In case two items claim the same disk location because the have the same parent and filename,
401    /// the system will choose to rename one of those items away from that location. The renamed item will
402    /// have the same parent, but a slightly modified name (for instance "a.txt" will be renamed to "a 2.txt").
403    ///
404    /// This can for instance happen if the case sensitivity of the local filesystem and of the provider differs.
405    ///
406    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingcollisionresolution?language=objc)
407    pub unsafe trait NSFileProviderTestingCollisionResolution:
408        NSFileProviderTestingOperation
409    {
410        /// The side of the operation.
411        #[unsafe(method(side))]
412        #[unsafe(method_family = none)]
413        unsafe fn side(&self) -> NSFileProviderTestingOperationSide;
414
415        #[cfg(feature = "NSFileProviderItem")]
416        /// The state of the item.
417        #[unsafe(method(renamedItem))]
418        #[unsafe(method_family = none)]
419        unsafe fn renamedItem(&self) -> Retained<NSFileProviderItem>;
420    }
421);