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/// Control the scheduling of operation.
129///
130/// These methods are available on domain with the NSFileProviderDomainTestingModeInteractive
131/// enabled.
132///
133/// In order to manually schedule the operation, the testing harness will first call
134/// -listAvailableTestingOperationWithError and get a list of operations that can be scheduled.
135/// It can pick one or more operations from that list and call -runTestingOperations:error: to
136/// schedule those operations.
137///
138/// From that point, it should get the new list of available operations and iterate between listing,
139/// picking operation, running those operation and so on.
140///
141/// A process must have the com.apple.developer.fileprovider.testing-mode entitlement in order to
142/// call the methods from this category.
143#[cfg(feature = "Extension")]
144impl NSFileProviderManager {
145    extern_methods!(
146        /// List the available operations.
147        ///
148        /// This lists all of the operations that are ready to be scheduled by the system. The system waits
149        /// for all the pending disk and working set updates to be known before returning.
150        ///
151        /// The operations that are returned may become invalid if the system receives new disk or working
152        /// set events, or if some operation are scheduled using -runTestingOperations:error:.
153        #[unsafe(method(listAvailableTestingOperationsWithError:_))]
154        #[unsafe(method_family = none)]
155        pub unsafe fn listAvailableTestingOperationsWithError(
156            &self,
157        ) -> Result<
158            Retained<NSArray<ProtocolObject<dyn NSFileProviderTestingOperation>>>,
159            Retained<NSError>,
160        >;
161
162        /// Run a set of operations.
163        ///
164        /// Ask the system to schedule the execution of the listed operations. The system will wait until all
165        /// those operations have completed and report a per-operation error in case an operation fails.
166        #[unsafe(method(runTestingOperations:error:_))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn runTestingOperations_error(
169            &self,
170            operations: &NSArray<ProtocolObject<dyn NSFileProviderTestingOperation>>,
171        ) -> Result<
172            Retained<NSDictionary<ProtocolObject<dyn NSFileProviderTestingOperation>, NSError>>,
173            Retained<NSError>,
174        >;
175    );
176}
177
178/// Side affected by the operation.
179///
180/// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingoperationside?language=objc)
181// NS_ENUM
182#[repr(transparent)]
183#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
184pub struct NSFileProviderTestingOperationSide(pub NSUInteger);
185impl NSFileProviderTestingOperationSide {
186    /// The operation reads or writes the disk.
187    #[doc(alias = "NSFileProviderTestingOperationSideDisk")]
188    pub const Disk: Self = Self(0);
189    /// The operation reads or writes the file provider extension.
190    #[doc(alias = "NSFileProviderTestingOperationSideFileProvider")]
191    pub const FileProvider: Self = Self(1);
192}
193
194unsafe impl Encode for NSFileProviderTestingOperationSide {
195    const ENCODING: Encoding = NSUInteger::ENCODING;
196}
197
198unsafe impl RefEncode for NSFileProviderTestingOperationSide {
199    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
200}
201
202extern_protocol!(
203    /// This operation causes the system to ingest a change.
204    ///
205    /// When running this operation, the system will discover a change from the disk or the provider.
206    ///
207    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingingestion?language=objc)
208    pub unsafe trait NSFileProviderTestingIngestion: NSFileProviderTestingOperation {
209        /// Side of the event.
210        #[unsafe(method(side))]
211        #[unsafe(method_family = none)]
212        unsafe fn side(&self) -> NSFileProviderTestingOperationSide;
213
214        #[cfg(feature = "NSFileProviderItem")]
215        /// Identifier of the affected item.
216        #[unsafe(method(itemIdentifier))]
217        #[unsafe(method_family = none)]
218        unsafe fn itemIdentifier(&self) -> Retained<NSFileProviderItemIdentifier>;
219
220        #[cfg(feature = "NSFileProviderItem")]
221        /// The metadata of the item.
222        ///
223        /// This will be nil if the item is being deleted.
224        #[unsafe(method(item))]
225        #[unsafe(method_family = none)]
226        unsafe fn item(&self) -> Option<Retained<NSFileProviderItem>>;
227    }
228);
229
230extern_protocol!(
231    /// This operation causes the system to lookup an item.
232    ///
233    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestinglookup?language=objc)
234    pub unsafe trait NSFileProviderTestingLookup: NSFileProviderTestingOperation {
235        /// Side of the event.
236        #[unsafe(method(side))]
237        #[unsafe(method_family = none)]
238        unsafe fn side(&self) -> NSFileProviderTestingOperationSide;
239
240        #[cfg(feature = "NSFileProviderItem")]
241        /// Identifier of the affected item.
242        #[unsafe(method(itemIdentifier))]
243        #[unsafe(method_family = none)]
244        unsafe fn itemIdentifier(&self) -> Retained<NSFileProviderItemIdentifier>;
245    }
246);
247
248extern_protocol!(
249    /// This operation causes the system to propagate a creation of an item from a source side to a target side.
250    ///
251    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingcreation?language=objc)
252    pub unsafe trait NSFileProviderTestingCreation: NSFileProviderTestingOperation {
253        /// The target side of the operation.
254        #[unsafe(method(targetSide))]
255        #[unsafe(method_family = none)]
256        unsafe fn targetSide(&self) -> NSFileProviderTestingOperationSide;
257
258        #[cfg(feature = "NSFileProviderItem")]
259        /// The description of the item.
260        #[unsafe(method(sourceItem))]
261        #[unsafe(method_family = none)]
262        unsafe fn sourceItem(&self) -> Retained<NSFileProviderItem>;
263
264        #[cfg(feature = "NSFileProviderDomain")]
265        /// The domain version at the time the creation was discovered on the source side.
266        #[unsafe(method(domainVersion))]
267        #[unsafe(method_family = none)]
268        unsafe fn domainVersion(&self) -> Option<Retained<NSFileProviderDomainVersion>>;
269    }
270);
271
272extern_protocol!(
273    /// This operation causes the system to propagate a modification of an existing item from a source side to a target side.
274    ///
275    /// The modification happens if a change is identified on an item that is already known by both sides.
276    ///
277    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingmodification?language=objc)
278    pub unsafe trait NSFileProviderTestingModification:
279        NSFileProviderTestingOperation
280    {
281        /// The target side of the operation.
282        #[unsafe(method(targetSide))]
283        #[unsafe(method_family = none)]
284        unsafe fn targetSide(&self) -> NSFileProviderTestingOperationSide;
285
286        #[cfg(feature = "NSFileProviderItem")]
287        /// The description of the item.
288        #[unsafe(method(sourceItem))]
289        #[unsafe(method_family = none)]
290        unsafe fn sourceItem(&self) -> Retained<NSFileProviderItem>;
291
292        #[cfg(feature = "NSFileProviderItem")]
293        /// The identifier of the target item.
294        #[unsafe(method(targetItemIdentifier))]
295        #[unsafe(method_family = none)]
296        unsafe fn targetItemIdentifier(&self) -> Retained<NSFileProviderItemIdentifier>;
297
298        #[cfg(feature = "NSFileProviderItem")]
299        /// The version of the target item on top of which the modification is applied
300        #[unsafe(method(targetItemBaseVersion))]
301        #[unsafe(method_family = none)]
302        unsafe fn targetItemBaseVersion(&self) -> Retained<NSFileProviderItemVersion>;
303
304        #[cfg(feature = "NSFileProviderItem")]
305        /// The list of updated fields.
306        #[unsafe(method(changedFields))]
307        #[unsafe(method_family = none)]
308        unsafe fn changedFields(&self) -> NSFileProviderItemFields;
309
310        #[cfg(feature = "NSFileProviderDomain")]
311        /// The domain version at the time the change was discovered on the source side.
312        #[unsafe(method(domainVersion))]
313        #[unsafe(method_family = none)]
314        unsafe fn domainVersion(&self) -> Option<Retained<NSFileProviderDomainVersion>>;
315    }
316);
317
318extern_protocol!(
319    /// This operation causes the system to propagate a deletion from a source side to a target side.
320    ///
321    /// The deletion happens if an item that is known by the target side is deleted on the source side.
322    ///
323    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingdeletion?language=objc)
324    pub unsafe trait NSFileProviderTestingDeletion: NSFileProviderTestingOperation {
325        /// The target side of the operation.
326        #[unsafe(method(targetSide))]
327        #[unsafe(method_family = none)]
328        unsafe fn targetSide(&self) -> NSFileProviderTestingOperationSide;
329
330        #[cfg(feature = "NSFileProviderItem")]
331        /// The identifier of the source item.
332        #[unsafe(method(sourceItemIdentifier))]
333        #[unsafe(method_family = none)]
334        unsafe fn sourceItemIdentifier(&self) -> Retained<NSFileProviderItemIdentifier>;
335
336        #[cfg(feature = "NSFileProviderItem")]
337        /// The identifier of the target item.
338        #[unsafe(method(targetItemIdentifier))]
339        #[unsafe(method_family = none)]
340        unsafe fn targetItemIdentifier(&self) -> Retained<NSFileProviderItemIdentifier>;
341
342        #[cfg(feature = "NSFileProviderItem")]
343        /// The version of the target item on top of which the deletion is applied
344        #[unsafe(method(targetItemBaseVersion))]
345        #[unsafe(method_family = none)]
346        unsafe fn targetItemBaseVersion(&self) -> Retained<NSFileProviderItemVersion>;
347
348        #[cfg(feature = "NSFileProviderDomain")]
349        /// The domain version at the time the change was discovered on the source side.
350        #[unsafe(method(domainVersion))]
351        #[unsafe(method_family = none)]
352        unsafe fn domainVersion(&self) -> Option<Retained<NSFileProviderDomainVersion>>;
353    }
354);
355
356extern_protocol!(
357    /// This operation causes the system to fetch the content of an item.
358    ///
359    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingcontentfetch?language=objc)
360    pub unsafe trait NSFileProviderTestingContentFetch:
361        NSFileProviderTestingOperation
362    {
363        /// The side of the operation.
364        #[unsafe(method(side))]
365        #[unsafe(method_family = none)]
366        unsafe fn side(&self) -> NSFileProviderTestingOperationSide;
367
368        #[cfg(feature = "NSFileProviderItem")]
369        /// The identifier of the item.
370        #[unsafe(method(itemIdentifier))]
371        #[unsafe(method_family = none)]
372        unsafe fn itemIdentifier(&self) -> Retained<NSFileProviderItemIdentifier>;
373    }
374);
375
376extern_protocol!(
377    /// This operation causes the system to list the children of an item
378    ///
379    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingchildrenenumeration?language=objc)
380    pub unsafe trait NSFileProviderTestingChildrenEnumeration:
381        NSFileProviderTestingOperation
382    {
383        /// The side of the operation.
384        #[unsafe(method(side))]
385        #[unsafe(method_family = none)]
386        unsafe fn side(&self) -> NSFileProviderTestingOperationSide;
387
388        #[cfg(feature = "NSFileProviderItem")]
389        /// The identifier of the item.
390        #[unsafe(method(itemIdentifier))]
391        #[unsafe(method_family = none)]
392        unsafe fn itemIdentifier(&self) -> Retained<NSFileProviderItemIdentifier>;
393    }
394);
395
396extern_protocol!(
397    /// This operation causes the system to resolve a collision by rename a colliding item.
398    ///
399    /// In case two items claim the same disk location because the have the same parent and filename,
400    /// the system will choose to rename one of those items away from that location. The renamed item will
401    /// have the same parent, but a slightly modified name (for instance "a.txt" will be renamed to "a 2.txt").
402    ///
403    /// This can for instance happen if the case sensitivity of the local filesystem and of the provider differs.
404    ///
405    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingcollisionresolution?language=objc)
406    pub unsafe trait NSFileProviderTestingCollisionResolution:
407        NSFileProviderTestingOperation
408    {
409        /// The side of the operation.
410        #[unsafe(method(side))]
411        #[unsafe(method_family = none)]
412        unsafe fn side(&self) -> NSFileProviderTestingOperationSide;
413
414        #[cfg(feature = "NSFileProviderItem")]
415        /// The state of the item.
416        #[unsafe(method(renamedItem))]
417        #[unsafe(method_family = none)]
418        unsafe fn renamedItem(&self) -> Retained<NSFileProviderItem>;
419    }
420);