objc2-file-provider 0.3.2

Bindings to the FileProvider framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

/// Type of the operation
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingoperationtype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSFileProviderTestingOperationType(pub NSInteger);
impl NSFileProviderTestingOperationType {
    #[doc(alias = "NSFileProviderTestingOperationTypeIngestion")]
    pub const Ingestion: Self = Self(0);
    #[doc(alias = "NSFileProviderTestingOperationTypeLookup")]
    pub const Lookup: Self = Self(1);
    #[doc(alias = "NSFileProviderTestingOperationTypeCreation")]
    pub const Creation: Self = Self(2);
    #[doc(alias = "NSFileProviderTestingOperationTypeModification")]
    pub const Modification: Self = Self(3);
    #[doc(alias = "NSFileProviderTestingOperationTypeDeletion")]
    pub const Deletion: Self = Self(4);
    #[doc(alias = "NSFileProviderTestingOperationTypeContentFetch")]
    pub const ContentFetch: Self = Self(5);
    #[doc(alias = "NSFileProviderTestingOperationTypeChildrenEnumeration")]
    pub const ChildrenEnumeration: Self = Self(6);
    #[doc(alias = "NSFileProviderTestingOperationTypeCollisionResolution")]
    pub const CollisionResolution: Self = Self(7);
}

unsafe impl Encode for NSFileProviderTestingOperationType {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for NSFileProviderTestingOperationType {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_protocol!(
    /// An operation that can scheduled.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingoperation?language=objc)
    pub unsafe trait NSFileProviderTestingOperation: NSObjectProtocol {
        /// The operation type
        #[unsafe(method(type))]
        #[unsafe(method_family = none)]
        unsafe fn r#type(&self) -> NSFileProviderTestingOperationType;

        /// Returns the operation as an Ingestion.
        ///
        /// Returns the operation if it conforms to NSFileProviderTestingIngestion, otherwise returns nil.
        #[unsafe(method(asIngestion))]
        #[unsafe(method_family = none)]
        unsafe fn asIngestion(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn NSFileProviderTestingIngestion>>>;

        /// Returns the operation as an Lookup.
        ///
        /// Returns the operation if it conforms to NSFileProviderTestingLookup, otherwise returns nil.
        #[unsafe(method(asLookup))]
        #[unsafe(method_family = none)]
        unsafe fn asLookup(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn NSFileProviderTestingLookup>>>;

        /// Returns the operation as an Creation.
        ///
        /// Returns the operation if it conforms to NSFileProviderTestingCreation, otherwise returns nil.
        #[unsafe(method(asCreation))]
        #[unsafe(method_family = none)]
        unsafe fn asCreation(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn NSFileProviderTestingCreation>>>;

        /// Returns the operation as an Modification.
        ///
        /// Returns the operation if it conforms to NSFileProviderTestingModification, otherwise returns nil.
        #[unsafe(method(asModification))]
        #[unsafe(method_family = none)]
        unsafe fn asModification(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn NSFileProviderTestingModification>>>;

        /// Returns the operation as an Deletion.
        ///
        /// Returns the operation if it conforms to NSFileProviderTestingDeletion, otherwise returns nil.
        #[unsafe(method(asDeletion))]
        #[unsafe(method_family = none)]
        unsafe fn asDeletion(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn NSFileProviderTestingDeletion>>>;

        /// Returns the operation as an ContentFetch.
        ///
        /// Returns the operation if it conforms to NSFileProviderTestingContentFetch, otherwise returns nil.
        #[unsafe(method(asContentFetch))]
        #[unsafe(method_family = none)]
        unsafe fn asContentFetch(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn NSFileProviderTestingContentFetch>>>;

        /// Returns the operation as an ChildrenEnumeration.
        ///
        /// Returns the operation if it conforms to NSFileProviderTestingChildrenEnumeration, otherwise returns nil.
        #[unsafe(method(asChildrenEnumeration))]
        #[unsafe(method_family = none)]
        unsafe fn asChildrenEnumeration(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn NSFileProviderTestingChildrenEnumeration>>>;

        /// Returns the operation as an Bounce.
        ///
        /// Returns the operation if it conforms to NSFileProviderTestingCollisionResolution, otherwise returns nil.
        #[unsafe(method(asCollisionResolution))]
        #[unsafe(method_family = none)]
        unsafe fn asCollisionResolution(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn NSFileProviderTestingCollisionResolution>>>;
    }
);

/// TestingModeInteractive.
///
/// Control the scheduling of operation.
///
/// These methods are available on domain with the NSFileProviderDomainTestingModeInteractive
/// enabled.
///
/// In order to manually schedule the operation, the testing harness will first call
/// -listAvailableTestingOperationWithError and get a list of operations that can be scheduled.
/// It can pick one or more operations from that list and call -runTestingOperations:error: to
/// schedule those operations.
///
/// From that point, it should get the new list of available operations and iterate between listing,
/// picking operation, running those operation and so on.
///
/// A process must have the com.apple.developer.fileprovider.testing-mode entitlement in order to
/// call the methods from this category.
#[cfg(feature = "Extension")]
impl NSFileProviderManager {
    extern_methods!(
        /// List the available operations.
        ///
        /// This lists all of the operations that are ready to be scheduled by the system. The system waits
        /// for all the pending disk and working set updates to be known before returning.
        ///
        /// The operations that are returned may become invalid if the system receives new disk or working
        /// set events, or if some operation are scheduled using -runTestingOperations:error:.
        #[unsafe(method(listAvailableTestingOperationsWithError:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn listAvailableTestingOperationsWithError(
            &self,
        ) -> Result<
            Retained<NSArray<ProtocolObject<dyn NSFileProviderTestingOperation>>>,
            Retained<NSError>,
        >;

        /// Run a set of operations.
        ///
        /// Ask the system to schedule the execution of the listed operations. The system will wait until all
        /// those operations have completed and report a per-operation error in case an operation fails.
        #[unsafe(method(runTestingOperations:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn runTestingOperations_error(
            &self,
            operations: &NSArray<ProtocolObject<dyn NSFileProviderTestingOperation>>,
        ) -> Result<
            Retained<NSDictionary<ProtocolObject<dyn NSFileProviderTestingOperation>, NSError>>,
            Retained<NSError>,
        >;
    );
}

/// Side affected by the operation.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingoperationside?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSFileProviderTestingOperationSide(pub NSUInteger);
impl NSFileProviderTestingOperationSide {
    /// The operation reads or writes the disk.
    #[doc(alias = "NSFileProviderTestingOperationSideDisk")]
    pub const Disk: Self = Self(0);
    /// The operation reads or writes the file provider extension.
    #[doc(alias = "NSFileProviderTestingOperationSideFileProvider")]
    pub const FileProvider: Self = Self(1);
}

unsafe impl Encode for NSFileProviderTestingOperationSide {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSFileProviderTestingOperationSide {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_protocol!(
    /// This operation causes the system to ingest a change.
    ///
    /// When running this operation, the system will discover a change from the disk or the provider.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingingestion?language=objc)
    pub unsafe trait NSFileProviderTestingIngestion: NSFileProviderTestingOperation {
        /// Side of the event.
        #[unsafe(method(side))]
        #[unsafe(method_family = none)]
        unsafe fn side(&self) -> NSFileProviderTestingOperationSide;

        #[cfg(feature = "NSFileProviderItem")]
        /// Identifier of the affected item.
        #[unsafe(method(itemIdentifier))]
        #[unsafe(method_family = none)]
        unsafe fn itemIdentifier(&self) -> Retained<NSFileProviderItemIdentifier>;

        #[cfg(feature = "NSFileProviderItem")]
        /// The metadata of the item.
        ///
        /// This will be nil if the item is being deleted.
        #[unsafe(method(item))]
        #[unsafe(method_family = none)]
        unsafe fn item(&self) -> Option<Retained<NSFileProviderItem>>;
    }
);

extern_protocol!(
    /// This operation causes the system to lookup an item.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestinglookup?language=objc)
    pub unsafe trait NSFileProviderTestingLookup: NSFileProviderTestingOperation {
        /// Side of the event.
        #[unsafe(method(side))]
        #[unsafe(method_family = none)]
        unsafe fn side(&self) -> NSFileProviderTestingOperationSide;

        #[cfg(feature = "NSFileProviderItem")]
        /// Identifier of the affected item.
        #[unsafe(method(itemIdentifier))]
        #[unsafe(method_family = none)]
        unsafe fn itemIdentifier(&self) -> Retained<NSFileProviderItemIdentifier>;
    }
);

extern_protocol!(
    /// This operation causes the system to propagate a creation of an item from a source side to a target side.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingcreation?language=objc)
    pub unsafe trait NSFileProviderTestingCreation: NSFileProviderTestingOperation {
        /// The target side of the operation.
        #[unsafe(method(targetSide))]
        #[unsafe(method_family = none)]
        unsafe fn targetSide(&self) -> NSFileProviderTestingOperationSide;

        #[cfg(feature = "NSFileProviderItem")]
        /// The description of the item.
        #[unsafe(method(sourceItem))]
        #[unsafe(method_family = none)]
        unsafe fn sourceItem(&self) -> Retained<NSFileProviderItem>;

        #[cfg(feature = "NSFileProviderDomain")]
        /// The domain version at the time the creation was discovered on the source side.
        #[unsafe(method(domainVersion))]
        #[unsafe(method_family = none)]
        unsafe fn domainVersion(&self) -> Option<Retained<NSFileProviderDomainVersion>>;
    }
);

extern_protocol!(
    /// This operation causes the system to propagate a modification of an existing item from a source side to a target side.
    ///
    /// The modification happens if a change is identified on an item that is already known by both sides.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingmodification?language=objc)
    pub unsafe trait NSFileProviderTestingModification:
        NSFileProviderTestingOperation
    {
        /// The target side of the operation.
        #[unsafe(method(targetSide))]
        #[unsafe(method_family = none)]
        unsafe fn targetSide(&self) -> NSFileProviderTestingOperationSide;

        #[cfg(feature = "NSFileProviderItem")]
        /// The description of the item.
        #[unsafe(method(sourceItem))]
        #[unsafe(method_family = none)]
        unsafe fn sourceItem(&self) -> Retained<NSFileProviderItem>;

        #[cfg(feature = "NSFileProviderItem")]
        /// The identifier of the target item.
        #[unsafe(method(targetItemIdentifier))]
        #[unsafe(method_family = none)]
        unsafe fn targetItemIdentifier(&self) -> Retained<NSFileProviderItemIdentifier>;

        #[cfg(feature = "NSFileProviderItem")]
        /// The version of the target item on top of which the modification is applied
        #[unsafe(method(targetItemBaseVersion))]
        #[unsafe(method_family = none)]
        unsafe fn targetItemBaseVersion(&self) -> Retained<NSFileProviderItemVersion>;

        #[cfg(feature = "NSFileProviderItem")]
        /// The list of updated fields.
        #[unsafe(method(changedFields))]
        #[unsafe(method_family = none)]
        unsafe fn changedFields(&self) -> NSFileProviderItemFields;

        #[cfg(feature = "NSFileProviderDomain")]
        /// The domain version at the time the change was discovered on the source side.
        #[unsafe(method(domainVersion))]
        #[unsafe(method_family = none)]
        unsafe fn domainVersion(&self) -> Option<Retained<NSFileProviderDomainVersion>>;
    }
);

extern_protocol!(
    /// This operation causes the system to propagate a deletion from a source side to a target side.
    ///
    /// The deletion happens if an item that is known by the target side is deleted on the source side.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingdeletion?language=objc)
    pub unsafe trait NSFileProviderTestingDeletion: NSFileProviderTestingOperation {
        /// The target side of the operation.
        #[unsafe(method(targetSide))]
        #[unsafe(method_family = none)]
        unsafe fn targetSide(&self) -> NSFileProviderTestingOperationSide;

        #[cfg(feature = "NSFileProviderItem")]
        /// The identifier of the source item.
        #[unsafe(method(sourceItemIdentifier))]
        #[unsafe(method_family = none)]
        unsafe fn sourceItemIdentifier(&self) -> Retained<NSFileProviderItemIdentifier>;

        #[cfg(feature = "NSFileProviderItem")]
        /// The identifier of the target item.
        #[unsafe(method(targetItemIdentifier))]
        #[unsafe(method_family = none)]
        unsafe fn targetItemIdentifier(&self) -> Retained<NSFileProviderItemIdentifier>;

        #[cfg(feature = "NSFileProviderItem")]
        /// The version of the target item on top of which the deletion is applied
        #[unsafe(method(targetItemBaseVersion))]
        #[unsafe(method_family = none)]
        unsafe fn targetItemBaseVersion(&self) -> Retained<NSFileProviderItemVersion>;

        #[cfg(feature = "NSFileProviderDomain")]
        /// The domain version at the time the change was discovered on the source side.
        #[unsafe(method(domainVersion))]
        #[unsafe(method_family = none)]
        unsafe fn domainVersion(&self) -> Option<Retained<NSFileProviderDomainVersion>>;
    }
);

extern_protocol!(
    /// This operation causes the system to fetch the content of an item.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingcontentfetch?language=objc)
    pub unsafe trait NSFileProviderTestingContentFetch:
        NSFileProviderTestingOperation
    {
        /// The side of the operation.
        #[unsafe(method(side))]
        #[unsafe(method_family = none)]
        unsafe fn side(&self) -> NSFileProviderTestingOperationSide;

        #[cfg(feature = "NSFileProviderItem")]
        /// The identifier of the item.
        #[unsafe(method(itemIdentifier))]
        #[unsafe(method_family = none)]
        unsafe fn itemIdentifier(&self) -> Retained<NSFileProviderItemIdentifier>;
    }
);

extern_protocol!(
    /// This operation causes the system to list the children of an item
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingchildrenenumeration?language=objc)
    pub unsafe trait NSFileProviderTestingChildrenEnumeration:
        NSFileProviderTestingOperation
    {
        /// The side of the operation.
        #[unsafe(method(side))]
        #[unsafe(method_family = none)]
        unsafe fn side(&self) -> NSFileProviderTestingOperationSide;

        #[cfg(feature = "NSFileProviderItem")]
        /// The identifier of the item.
        #[unsafe(method(itemIdentifier))]
        #[unsafe(method_family = none)]
        unsafe fn itemIdentifier(&self) -> Retained<NSFileProviderItemIdentifier>;
    }
);

extern_protocol!(
    /// This operation causes the system to resolve a collision by rename a colliding item.
    ///
    /// In case two items claim the same disk location because the have the same parent and filename,
    /// the system will choose to rename one of those items away from that location. The renamed item will
    /// have the same parent, but a slightly modified name (for instance "a.txt" will be renamed to "a 2.txt").
    ///
    /// This can for instance happen if the case sensitivity of the local filesystem and of the provider differs.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/fileprovider/nsfileprovidertestingcollisionresolution?language=objc)
    pub unsafe trait NSFileProviderTestingCollisionResolution:
        NSFileProviderTestingOperation
    {
        /// The side of the operation.
        #[unsafe(method(side))]
        #[unsafe(method_family = none)]
        unsafe fn side(&self) -> NSFileProviderTestingOperationSide;

        #[cfg(feature = "NSFileProviderItem")]
        /// The state of the item.
        #[unsafe(method(renamedItem))]
        #[unsafe(method_family = none)]
        unsafe fn renamedItem(&self) -> Retained<NSFileProviderItem>;
    }
);