cidre 0.14.0

Apple frameworks bindings for rust
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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
use std::marker::PhantomData;

use crate::{api, arc, define_cls, ns, objc, ui};

#[cfg(feature = "blocks")]
use crate::blocks;

#[cfg(feature = "blocks")]
pub type CollectionViewDiffableDataSrcCellProvider<I> = blocks::EscBlock<
    fn(&ui::CollectionView, &ns::IndexPath, &I) -> Option<arc::R<ui::CollectionViewCell>>,
>;

#[cfg(feature = "blocks")]
pub type CollectionViewDiffableDataSrcSupplementaryViewProvider = blocks::EscBlock<
    fn(
        &ui::CollectionView,
        &ns::String,
        &ns::IndexPath,
    ) -> Option<arc::R<ui::CollectionReusableView>>,
>;

#[doc(alias = "NSDiffableDataSourceSectionTransaction")]
#[repr(transparent)]
pub struct DiffableDataSrcSectionTransaction<S, I>(ns::Id, PhantomData<S>, PhantomData<I>);

impl<S: objc::Obj, I: objc::Obj> objc::Obj for DiffableDataSrcSectionTransaction<S, I> {}

impl<S: objc::Obj, I: objc::Obj> DiffableDataSrcSectionTransaction<S, I> {
    #[objc::msg_send(sectionIdentifier)]
    pub fn section_id(&self) -> arc::R<S>;

    #[objc::msg_send(initialSnapshot)]
    pub fn initial_snapshot(&self) -> arc::R<ns::DiffableDataSrcSectionSnapshot<I>>;

    #[objc::msg_send(finalSnapshot)]
    pub fn final_snapshot(&self) -> arc::R<ns::DiffableDataSrcSectionSnapshot<I>>;

    #[objc::msg_send(difference)]
    pub fn difference(&self) -> arc::R<ns::OrderedCollectionDiff<I>>;
}

#[doc(alias = "NSDiffableDataSourceTransaction")]
#[repr(transparent)]
pub struct DiffableDataSrcTransaction<S, I>(ns::Id, PhantomData<S>, PhantomData<I>);

impl<S: objc::Obj, I: objc::Obj> objc::Obj for DiffableDataSrcTransaction<S, I> {}

impl<S: objc::Obj, I: objc::Obj> DiffableDataSrcTransaction<S, I> {
    #[objc::msg_send(initialSnapshot)]
    pub fn initial_snapshot(&self) -> arc::R<ns::DiffableDataSrcSnapshot<S, I>>;

    #[objc::msg_send(finalSnapshot)]
    pub fn final_snapshot(&self) -> arc::R<ns::DiffableDataSrcSnapshot<S, I>>;

    #[objc::msg_send(difference)]
    pub fn difference(&self) -> arc::R<ns::OrderedCollectionDiff<I>>;

    #[objc::msg_send(sectionTransactions)]
    pub fn section_transactions(
        &self,
    ) -> arc::R<ns::Array<DiffableDataSrcSectionTransaction<S, I>>>;
}

#[doc(alias = "UICollectionViewDiffableDataSourceReorderingHandlers")]
#[repr(transparent)]
pub struct CollectionViewDiffableDataSrcReorderingHandlers<S, I>(
    ns::Id,
    PhantomData<S>,
    PhantomData<I>,
);

impl<S: objc::Obj, I: objc::Obj> objc::Obj
    for CollectionViewDiffableDataSrcReorderingHandlers<S, I>
{
}

impl<S: objc::Obj, I: objc::Obj> arc::A<CollectionViewDiffableDataSrcReorderingHandlers<S, I>> {
    #[objc::msg_send(init)]
    pub fn init(self) -> arc::R<CollectionViewDiffableDataSrcReorderingHandlers<S, I>>;
}

impl<S: objc::Obj + 'static, I: objc::Obj + 'static>
    CollectionViewDiffableDataSrcReorderingHandlers<S, I>
{
    define_cls!(UI_COLLECTION_VIEW_DIFFABLE_DATA_SOURCE_REORDERING_HANDLERS);

    #[inline]
    pub fn new() -> arc::R<Self> {
        Self::alloc().init()
    }

    #[cfg(feature = "blocks")]
    #[objc::msg_send(canReorderItemHandler)]
    pub fn can_reorder_item_handler(&self) -> Option<arc::R<blocks::EscBlock<fn(&I) -> bool>>>;

    #[cfg(feature = "blocks")]
    #[objc::msg_send(setCanReorderItemHandler:)]
    pub fn set_can_reorder_item_handler_block(
        &mut self,
        handler: Option<&mut blocks::EscBlock<fn(&I) -> bool>>,
    );

    #[cfg(feature = "blocks")]
    pub fn set_can_reorder_item_handler(&mut self, handler: impl FnMut(&I) -> bool + 'static) {
        let mut handler = blocks::EscBlock::new1(handler);
        self.set_can_reorder_item_handler_block(Some(&mut handler));
    }

    #[cfg(feature = "blocks")]
    #[objc::msg_send(willReorderHandler)]
    pub fn will_reorder_handler(
        &self,
    ) -> Option<arc::R<blocks::EscBlock<fn(&DiffableDataSrcTransaction<S, I>)>>>;

    #[cfg(feature = "blocks")]
    #[objc::msg_send(setWillReorderHandler:)]
    pub fn set_will_reorder_handler_block(
        &mut self,
        handler: Option<&mut blocks::EscBlock<fn(&DiffableDataSrcTransaction<S, I>)>>,
    );

    #[cfg(feature = "blocks")]
    pub fn set_will_reorder_handler(
        &mut self,
        handler: impl FnMut(&DiffableDataSrcTransaction<S, I>) + 'static,
    ) {
        let mut handler = blocks::EscBlock::new1(handler);
        self.set_will_reorder_handler_block(Some(&mut handler));
    }

    #[cfg(feature = "blocks")]
    #[objc::msg_send(didReorderHandler)]
    pub fn did_reorder_handler(
        &self,
    ) -> Option<arc::R<blocks::EscBlock<fn(&DiffableDataSrcTransaction<S, I>)>>>;

    #[cfg(feature = "blocks")]
    #[objc::msg_send(setDidReorderHandler:)]
    pub fn set_did_reorder_handler_block(
        &mut self,
        handler: Option<&mut blocks::EscBlock<fn(&DiffableDataSrcTransaction<S, I>)>>,
    );

    #[cfg(feature = "blocks")]
    pub fn set_did_reorder_handler(
        &mut self,
        handler: impl FnMut(&DiffableDataSrcTransaction<S, I>) + 'static,
    ) {
        let mut handler = blocks::EscBlock::new1(handler);
        self.set_did_reorder_handler_block(Some(&mut handler));
    }
}

#[doc(alias = "UICollectionViewDiffableDataSourceSectionSnapshotHandlers")]
#[repr(transparent)]
pub struct CollectionViewDiffableDataSrcSectionSnapshotHandlers<I>(ns::Id, PhantomData<I>);

impl<I: objc::Obj> objc::Obj for CollectionViewDiffableDataSrcSectionSnapshotHandlers<I> {}

impl<I: objc::Obj> arc::A<CollectionViewDiffableDataSrcSectionSnapshotHandlers<I>> {
    #[objc::msg_send(init)]
    pub fn init(self) -> arc::R<CollectionViewDiffableDataSrcSectionSnapshotHandlers<I>>;
}

impl<I: objc::Obj + 'static> CollectionViewDiffableDataSrcSectionSnapshotHandlers<I> {
    define_cls!(UI_COLLECTION_VIEW_DIFFABLE_DATA_SOURCE_SECTION_SNAPSHOT_HANDLERS);

    #[inline]
    pub fn new() -> arc::R<Self> {
        Self::alloc().init()
    }

    #[cfg(feature = "blocks")]
    #[objc::msg_send(shouldExpandItemHandler)]
    pub fn should_expand_item_handler(&self) -> Option<arc::R<blocks::EscBlock<fn(&I) -> bool>>>;

    #[cfg(feature = "blocks")]
    #[objc::msg_send(setShouldExpandItemHandler:)]
    pub fn set_should_expand_item_handler_block(
        &mut self,
        handler: Option<&mut blocks::EscBlock<fn(&I) -> bool>>,
    );

    #[cfg(feature = "blocks")]
    pub fn set_should_expand_item_handler(&mut self, handler: impl FnMut(&I) -> bool + 'static) {
        let mut handler = blocks::EscBlock::new1(handler);
        self.set_should_expand_item_handler_block(Some(&mut handler));
    }

    #[cfg(feature = "blocks")]
    #[objc::msg_send(willExpandItemHandler)]
    pub fn will_expand_item_handler(&self) -> Option<arc::R<blocks::EscBlock<fn(&I)>>>;

    #[cfg(feature = "blocks")]
    #[objc::msg_send(setWillExpandItemHandler:)]
    pub fn set_will_expand_item_handler_block(
        &mut self,
        handler: Option<&mut blocks::EscBlock<fn(&I)>>,
    );

    #[cfg(feature = "blocks")]
    pub fn set_will_expand_item_handler(&mut self, handler: impl FnMut(&I) + 'static) {
        let mut handler = blocks::EscBlock::new1(handler);
        self.set_will_expand_item_handler_block(Some(&mut handler));
    }

    #[cfg(feature = "blocks")]
    #[objc::msg_send(shouldCollapseItemHandler)]
    pub fn should_collapse_item_handler(&self) -> Option<arc::R<blocks::EscBlock<fn(&I) -> bool>>>;

    #[cfg(feature = "blocks")]
    #[objc::msg_send(setShouldCollapseItemHandler:)]
    pub fn set_should_collapse_item_handler_block(
        &mut self,
        handler: Option<&mut blocks::EscBlock<fn(&I) -> bool>>,
    );

    #[cfg(feature = "blocks")]
    pub fn set_should_collapse_item_handler(&mut self, handler: impl FnMut(&I) -> bool + 'static) {
        let mut handler = blocks::EscBlock::new1(handler);
        self.set_should_collapse_item_handler_block(Some(&mut handler));
    }

    #[cfg(feature = "blocks")]
    #[objc::msg_send(willCollapseItemHandler)]
    pub fn will_collapse_item_handler(&self) -> Option<arc::R<blocks::EscBlock<fn(&I)>>>;

    #[cfg(feature = "blocks")]
    #[objc::msg_send(setWillCollapseItemHandler:)]
    pub fn set_will_collapse_item_handler_block(
        &mut self,
        handler: Option<&mut blocks::EscBlock<fn(&I)>>,
    );

    #[cfg(feature = "blocks")]
    pub fn set_will_collapse_item_handler(&mut self, handler: impl FnMut(&I) + 'static) {
        let mut handler = blocks::EscBlock::new1(handler);
        self.set_will_collapse_item_handler_block(Some(&mut handler));
    }

    #[cfg(feature = "blocks")]
    #[objc::msg_send(snapshotForExpandingParentItemHandler)]
    pub fn snapshot_for_expanding_parent_item_handler(
        &self,
    ) -> Option<
        arc::R<
            blocks::EscBlock<
                fn(
                    &I,
                    &ns::DiffableDataSrcSectionSnapshot<I>,
                ) -> arc::R<ns::DiffableDataSrcSectionSnapshot<I>>,
            >,
        >,
    >;

    #[cfg(feature = "blocks")]
    #[objc::msg_send(setSnapshotForExpandingParentItemHandler:)]
    pub fn set_snapshot_for_expanding_parent_item_handler_block(
        &mut self,
        handler: Option<
            &mut blocks::EscBlock<
                fn(
                    &I,
                    &ns::DiffableDataSrcSectionSnapshot<I>,
                ) -> arc::R<ns::DiffableDataSrcSectionSnapshot<I>>,
            >,
        >,
    );

    #[cfg(feature = "blocks")]
    pub fn set_snapshot_for_expanding_parent_item_handler(
        &mut self,
        handler: impl FnMut(
            &I,
            &ns::DiffableDataSrcSectionSnapshot<I>,
        ) -> arc::R<ns::DiffableDataSrcSectionSnapshot<I>>
        + 'static,
    ) {
        let mut handler = blocks::EscBlock::new2(handler);
        self.set_snapshot_for_expanding_parent_item_handler_block(Some(&mut handler));
    }
}

#[doc(alias = "UICollectionViewDiffableDataSource")]
#[repr(transparent)]
pub struct CollectionViewDiffableDataSrc<S, I>(ns::Id, PhantomData<S>, PhantomData<I>);

impl<S: objc::Obj, I: objc::Obj> objc::Obj for CollectionViewDiffableDataSrc<S, I> {}

impl<S: objc::Obj, I: objc::Obj> arc::A<CollectionViewDiffableDataSrc<S, I>> {
    #[cfg(feature = "blocks")]
    #[objc::msg_send(initWithCollectionView:cellProvider:)]
    pub fn init_with_collection_view_cell_provider(
        self,
        collection_view: &ui::CollectionView,
        cell_provider: &mut CollectionViewDiffableDataSrcCellProvider<I>,
    ) -> arc::R<CollectionViewDiffableDataSrc<S, I>>;
}

impl<S: objc::Obj, I: objc::Obj> CollectionViewDiffableDataSrc<S, I> {
    define_cls!(UI_COLLECTION_VIEW_DIFFABLE_DATA_SOURCE);

    #[cfg(feature = "blocks")]
    pub fn with_collection_view_cell_provider(
        collection_view: &ui::CollectionView,
        cell_provider: impl FnMut(
            &ui::CollectionView,
            &ns::IndexPath,
            &I,
        ) -> Option<arc::R<ui::CollectionViewCell>>
        + 'static,
    ) -> arc::R<Self> {
        let mut cell_provider = CollectionViewDiffableDataSrcCellProvider::new3(cell_provider);
        Self::alloc().init_with_collection_view_cell_provider(collection_view, &mut cell_provider)
    }

    #[cfg(feature = "blocks")]
    #[objc::msg_send(supplementaryViewProvider)]
    pub fn supplementary_view_provider(
        &self,
    ) -> Option<arc::R<CollectionViewDiffableDataSrcSupplementaryViewProvider>>;

    #[cfg(feature = "blocks")]
    #[objc::msg_send(setSupplementaryViewProvider:)]
    pub fn set_supplementary_view_provider_block(
        &mut self,
        provider: Option<&mut CollectionViewDiffableDataSrcSupplementaryViewProvider>,
    );

    #[cfg(feature = "blocks")]
    pub fn set_supplementary_view_provider(
        &mut self,
        provider: impl FnMut(
            &ui::CollectionView,
            &ns::String,
            &ns::IndexPath,
        ) -> Option<arc::R<ui::CollectionReusableView>>
        + 'static,
    ) {
        let mut provider = CollectionViewDiffableDataSrcSupplementaryViewProvider::new3(provider);
        self.set_supplementary_view_provider_block(Some(&mut provider));
    }

    #[objc::msg_send(snapshot)]
    pub fn snapshot(&self) -> arc::R<ns::DiffableDataSrcSnapshot<S, I>>;

    #[objc::msg_send(applySnapshot:animatingDifferences:)]
    pub fn apply_snapshot_animating_differences(
        &mut self,
        snapshot: &ns::DiffableDataSrcSnapshot<S, I>,
        animating_differences: bool,
    );

    #[cfg(feature = "blocks")]
    #[objc::msg_send(applySnapshot:animatingDifferences:completion:)]
    pub fn apply_snapshot_animating_differences_completion(
        &mut self,
        snapshot: &ns::DiffableDataSrcSnapshot<S, I>,
        animating_differences: bool,
        completion: Option<&mut blocks::CompletionBlock>,
    );

    #[cfg(feature = "blocks")]
    pub fn apply_snapshot_animating_differences_with_completion(
        &mut self,
        snapshot: &ns::DiffableDataSrcSnapshot<S, I>,
        animating_differences: bool,
        completion: impl FnMut() + 'static,
    ) {
        let mut completion = blocks::CompletionBlock::new0(completion);
        self.apply_snapshot_animating_differences_completion(
            snapshot,
            animating_differences,
            Some(&mut completion),
        );
    }

    #[api::available(ios = 15.0, tvos = 15.0)]
    #[objc::msg_send(applySnapshotUsingReloadData:)]
    pub fn apply_snapshot_using_reload_data(
        &mut self,
        snapshot: &ns::DiffableDataSrcSnapshot<S, I>,
    );

    #[cfg(feature = "blocks")]
    #[api::available(ios = 15.0, tvos = 15.0)]
    #[objc::msg_send(applySnapshotUsingReloadData:completion:)]
    pub fn apply_snapshot_using_reload_data_completion(
        &mut self,
        snapshot: &ns::DiffableDataSrcSnapshot<S, I>,
        completion: Option<&mut blocks::CompletionBlock>,
    );

    #[cfg(feature = "blocks")]
    #[api::available(ios = 15.0, tvos = 15.0)]
    pub fn apply_snapshot_using_reload_data_with_completion(
        &mut self,
        snapshot: &ns::DiffableDataSrcSnapshot<S, I>,
        completion: impl FnMut() + 'static,
    ) {
        let mut completion = blocks::CompletionBlock::new0(completion);
        self.apply_snapshot_using_reload_data_completion(snapshot, Some(&mut completion));
    }

    #[api::available(ios = 15.0, tvos = 15.0)]
    #[objc::msg_send(sectionIdentifierForIndex:)]
    pub fn section_id_for_index(&self, index: ns::Integer) -> Option<arc::R<S>>;

    #[api::available(ios = 15.0, tvos = 15.0)]
    #[objc::msg_send(indexForSectionIdentifier:)]
    pub fn index_for_section_id(&self, section_id: &S) -> ns::Integer;

    #[objc::msg_send(itemIdentifierForIndexPath:)]
    pub fn item_id_for_index_path(&self, index_path: &ns::IndexPath) -> Option<arc::R<I>>;

    #[objc::msg_send(indexPathForItemIdentifier:)]
    pub fn index_path_for_item_id(&self, item_id: &I) -> Option<arc::R<ns::IndexPath>>;

    #[api::available(ios = 14.0, tvos = 14.0)]
    #[objc::msg_send(reorderingHandlers)]
    pub fn reordering_handlers(
        &self,
    ) -> arc::R<CollectionViewDiffableDataSrcReorderingHandlers<S, I>>;

    #[api::available(ios = 14.0, tvos = 14.0)]
    #[objc::msg_send(setReorderingHandlers:)]
    pub fn set_reordering_handlers(
        &mut self,
        handlers: &CollectionViewDiffableDataSrcReorderingHandlers<S, I>,
    );

    #[api::available(ios = 14.0, tvos = 14.0)]
    #[objc::msg_send(applySnapshot:toSection:animatingDifferences:)]
    pub fn apply_section_snapshot_animating_differences(
        &mut self,
        snapshot: &ns::DiffableDataSrcSectionSnapshot<I>,
        section_id: &S,
        animating_differences: bool,
    );

    #[cfg(feature = "blocks")]
    #[api::available(ios = 14.0, tvos = 14.0)]
    #[objc::msg_send(applySnapshot:toSection:animatingDifferences:completion:)]
    pub fn apply_section_snapshot_animating_differences_completion(
        &mut self,
        snapshot: &ns::DiffableDataSrcSectionSnapshot<I>,
        section_id: &S,
        animating_differences: bool,
        completion: Option<&mut blocks::CompletionBlock>,
    );

    #[cfg(feature = "blocks")]
    #[api::available(ios = 14.0, tvos = 14.0)]
    pub fn apply_section_snapshot_animating_differences_with_completion(
        &mut self,
        snapshot: &ns::DiffableDataSrcSectionSnapshot<I>,
        section_id: &S,
        animating_differences: bool,
        completion: impl FnMut() + 'static,
    ) {
        let mut completion = blocks::CompletionBlock::new0(completion);
        self.apply_section_snapshot_animating_differences_completion(
            snapshot,
            section_id,
            animating_differences,
            Some(&mut completion),
        );
    }

    #[api::available(ios = 14.0, tvos = 14.0)]
    #[objc::msg_send(snapshotForSection:)]
    pub fn snapshot_for_section(
        &self,
        section_id: &S,
    ) -> arc::R<ns::DiffableDataSrcSectionSnapshot<I>>;

    #[api::available(ios = 14.0, tvos = 14.0)]
    #[objc::msg_send(sectionSnapshotHandlers)]
    pub fn section_snapshot_handlers(
        &self,
    ) -> arc::R<CollectionViewDiffableDataSrcSectionSnapshotHandlers<I>>;

    #[api::available(ios = 14.0, tvos = 14.0)]
    #[objc::msg_send(setSectionSnapshotHandlers:)]
    pub fn set_section_snapshot_handlers(
        &mut self,
        handlers: &CollectionViewDiffableDataSrcSectionSnapshotHandlers<I>,
    );
}

impl<S: objc::Obj, I: objc::Obj> ui::CollectionViewDataSrc for CollectionViewDiffableDataSrc<S, I> {}

#[link(name = "ui", kind = "static")]
unsafe extern "C" {
    static UI_COLLECTION_VIEW_DIFFABLE_DATA_SOURCE:
        &'static objc::Class<CollectionViewDiffableDataSrc<ns::Id, ns::Id>>;
    static UI_COLLECTION_VIEW_DIFFABLE_DATA_SOURCE_REORDERING_HANDLERS:
        &'static objc::Class<CollectionViewDiffableDataSrcReorderingHandlers<ns::Id, ns::Id>>;
    static UI_COLLECTION_VIEW_DIFFABLE_DATA_SOURCE_SECTION_SNAPSHOT_HANDLERS:
        &'static objc::Class<CollectionViewDiffableDataSrcSectionSnapshotHandlers<ns::Id>>;
}