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
use crate::{api, arc, av, cg, define_obj_type, ns, objc};

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

define_obj_type!(
    #[doc(alias = "AVMetadataObjectType")]
    pub Type(ns::String)
);

impl Type {
    #[doc(alias = "AVMetadataObjectTypeHumanBody")]
    #[inline]
    pub fn human_body() -> &'static Type {
        unsafe { AVMetadataObjectTypeHumanBody }
    }

    #[doc(alias = "AVMetadataObjectTypeHumanFullBody")]
    #[inline]
    pub fn human_full_body() -> &'static Type {
        unsafe { AVMetadataObjectTypeHumanFullBody }
    }

    #[doc(alias = "AVMetadataObjectTypeCatBody")]
    #[inline]
    pub fn cat_body() -> &'static Type {
        unsafe { AVMetadataObjectTypeCatBody }
    }

    #[doc(alias = "AVMetadataObjectTypeDogBody")]
    #[inline]
    pub fn dog_body() -> &'static Type {
        unsafe { AVMetadataObjectTypeDogBody }
    }

    #[doc(alias = "AVMetadataObjectTypeSalientObject")]
    #[inline]
    pub fn salient_object() -> &'static Type {
        unsafe { AVMetadataObjectTypeSalientObject }
    }

    #[doc(alias = "AVMetadataObjectTypeFace")]
    #[inline]
    pub fn face() -> &'static Type {
        unsafe { AVMetadataObjectTypeFace }
    }

    /// objects generated from UPC-E codes return this constant as their type.
    #[doc(alias = "AVMetadataObjectTypeUPCECode")]
    #[inline]
    pub fn upc_e_code() -> &'static Type {
        unsafe { AVMetadataObjectTypeUPCECode }
    }

    /// objects generated from Code 39 codes return this constant as their type.
    #[doc(alias = "AVMetadataObjectTypeCode39Code")]
    #[inline]
    pub fn code_39_code() -> &'static Type {
        unsafe { AVMetadataObjectTypeCode39Code }
    }

    /// objects generated from Code 39 mod 43 codes return this constant as their type.
    #[doc(alias = "AVMetadataObjectTypeCode39Mod43Code")]
    #[inline]
    pub fn code_39_mod_43_code() -> &'static Type {
        unsafe { AVMetadataObjectTypeCode39Mod43Code }
    }

    /// objects generated from EAN-13 (including UPC-A) codes return this constant as their type.
    #[doc(alias = "AVMetadataObjectTypeEAN13Code")]
    #[inline]
    pub fn ean_13_code() -> &'static Type {
        unsafe { AVMetadataObjectTypeEAN13Code }
    }

    /// objects generated from EAN-8 codes return this constant as their type.
    #[doc(alias = "AVMetadataObjectTypeEAN8Code")]
    #[inline]
    pub fn ean_8_code() -> &'static Type {
        unsafe { AVMetadataObjectTypeEAN8Code }
    }

    /// objects generated from Code 93 codes return this constant as their type.
    #[doc(alias = "AVMetadataObjectTypeCode93Code")]
    #[inline]
    pub fn code_93_code() -> &'static Type {
        unsafe { AVMetadataObjectTypeCode93Code }
    }

    /// objects generated from Code 128 codes return this constant as their type.
    #[doc(alias = "AVMetadataObjectTypeCode128Code")]
    #[inline]
    pub fn code_128_code() -> &'static Type {
        unsafe { AVMetadataObjectTypeCode128Code }
    }

    /// objects generated from PDF417 codes return this constant as their type
    #[doc(alias = "AVMetadataObjectTypePDF417Code")]
    #[inline]
    pub fn pdf_417_code() -> &'static Type {
        unsafe { AVMetadataObjectTypePDF417Code }
    }

    /// objects generated from QR codes return this constant as their type.
    #[doc(alias = "AVMetadataObjectTypeQRCode")]
    #[inline]
    pub fn qr_code() -> &'static Type {
        unsafe { AVMetadataObjectTypeQRCode }
    }

    /// objects generated from Aztec codes return this constant as their type.
    #[doc(alias = "AVMetadataObjectTypeAztecCode")]
    #[inline]
    pub fn aztec_code() -> &'static Type {
        unsafe { AVMetadataObjectTypeAztecCode }
    }

    /// objects generated from Interleaved 2 of 5 codes return this constant as their type.
    #[doc(alias = "AVMetadataObjectTypeInterleaved2of5Code")]
    #[inline]
    pub fn interleaved_2_to_5_code() -> &'static Type {
        unsafe { AVMetadataObjectTypeInterleaved2of5Code }
    }

    /// objects generated from ITF14 codes return this constant as their type.
    #[doc(alias = "AVMetadataObjectTypeITF14Code")]
    #[inline]
    pub fn itf_14_code() -> &'static Type {
        unsafe { AVMetadataObjectTypeITF14Code }
    }

    /// objects generated from DataMatrix codes return this constant as their type.
    #[doc(alias = "AVMetadataObjectTypeDataMatrixCode")]
    #[inline]
    pub fn data_matrix_code() -> &'static Type {
        unsafe { AVMetadataObjectTypeDataMatrixCode }
    }

    /// objects generated from Codabar codes return this constant as their type.
    #[doc(alias = "AVMetadataObjectTypeCodabarCode")]
    #[inline]
    pub fn codebar_code() -> &'static Type {
        unsafe { AVMetadataObjectTypeCodabarCode }
    }

    /// objects generated from GS1DataBar codes return this constant as their type.
    #[doc(alias = "AVMetadataObjectTypeGS1DataBarCode")]
    #[inline]
    pub fn gs_1_data_bar_code() -> &'static Type {
        unsafe { AVMetadataObjectTypeGS1DataBarCode }
    }

    /// objects generated from GS1DataBarExpanded codes return this constant as their type.
    #[doc(alias = "AVMetadataObjectTypeGS1DataBarExpandedCode")]
    #[inline]
    pub fn gs_1_data_bar_expanded_code() -> &'static Type {
        unsafe { AVMetadataObjectTypeGS1DataBarExpandedCode }
    }

    /// objects generated from GS1DataBarLimited codes return this constant as their type.
    #[doc(alias = "AVMetadataObjectTypeGS1DataBarLimitedCode")]
    #[inline]
    pub fn gs_1_data_bar_limited_code() -> &'static Type {
        unsafe { AVMetadataObjectTypeGS1DataBarLimitedCode }
    }

    /// objects generated from MicroQR codes return this constant as their type.
    #[doc(alias = "AVMetadataObjectTypeMicroQRCode")]
    #[inline]
    pub fn micro_qr_code() -> &'static Type {
        unsafe { AVMetadataObjectTypeMicroQRCode }
    }

    /// objects generated from MicroPDF417 codes return this constant as their type.
    #[doc(alias = "AVMetadataObjectTypeMicroPDF417Code")]
    #[inline]
    pub fn micro_pdf_417_code() -> &'static Type {
        unsafe { AVMetadataObjectTypeMicroPDF417Code }
    }

    #[api::available(macos = 26.0, ios = 26.0, maccatalyst = 26.0, tvos = 26.0)]
    pub fn cat_head() -> &'static Type {
        unsafe { AVMetadataObjectTypeCatHead }
    }

    #[api::available(macos = 26.0, ios = 26.0, maccatalyst = 26.0, tvos = 26.0)]
    pub fn dog_head() -> &'static Type {
        unsafe { AVMetadataObjectTypeDogHead }
    }
}

#[api::weak]
unsafe extern "C" {
    static AVMetadataObjectTypeHumanBody: &'static Type;
    static AVMetadataObjectTypeHumanFullBody: &'static Type;
    static AVMetadataObjectTypeCatBody: &'static Type;
    static AVMetadataObjectTypeDogBody: &'static Type;
    static AVMetadataObjectTypeSalientObject: &'static Type;
    static AVMetadataObjectTypeFace: &'static Type;
    static AVMetadataObjectTypeUPCECode: &'static Type;
    static AVMetadataObjectTypeCode39Code: &'static Type;
    static AVMetadataObjectTypeCode39Mod43Code: &'static Type;
    static AVMetadataObjectTypeEAN13Code: &'static Type;
    static AVMetadataObjectTypeEAN8Code: &'static Type;
    static AVMetadataObjectTypeCode93Code: &'static Type;
    static AVMetadataObjectTypeCode128Code: &'static Type;
    static AVMetadataObjectTypePDF417Code: &'static Type;
    static AVMetadataObjectTypeQRCode: &'static Type;
    static AVMetadataObjectTypeAztecCode: &'static Type;
    static AVMetadataObjectTypeInterleaved2of5Code: &'static Type;
    static AVMetadataObjectTypeITF14Code: &'static Type;
    static AVMetadataObjectTypeDataMatrixCode: &'static Type;
    static AVMetadataObjectTypeCodabarCode: &'static Type;
    static AVMetadataObjectTypeGS1DataBarCode: &'static Type;
    static AVMetadataObjectTypeGS1DataBarExpandedCode: &'static Type;
    static AVMetadataObjectTypeGS1DataBarLimitedCode: &'static Type;
    static AVMetadataObjectTypeMicroQRCode: &'static Type;
    static AVMetadataObjectTypeMicroPDF417Code: &'static Type;

    #[api::available(macos = 26.0, ios = 26.0, maccatalyst = 26.0, tvos = 26.0)]
    static AVMetadataObjectTypeCatHead: &'static Type;

    #[api::available(macos = 26.0, ios = 26.0, maccatalyst = 26.0, tvos = 26.0)]
    static AVMetadataObjectTypeDogHead: &'static Type;
}

define_obj_type!(
    #[doc(alias = "AVMetadataObject")]
    pub Obj(ns::Id)
);

impl Obj {
    /// The value of this property is a cg::Rect representing the bounding rectangle
    /// of the object with respect to the picture in which it resides. The rectangle's
    /// origin is top left. If the metadata originates from video, bounds may be
    /// expressed as scalar values from 0. - 1. If the original video has been scaled
    /// down, the bounds of the metadata object still are meaningful. This property may
    /// return cg::Rect::zero if the metadata has no bounds.
    #[objc::msg_send(bounds)]
    pub fn bounds(&self) -> cg::Rect;

    /// The media time associated with this metadata object.
    ///
    /// The value of this property is a cm::Time associated with the metadata object.
    /// For capture, it is the time at which this object was captured. If this metadata
    /// object originates from a cm::SampleBuffer, its time matches the sample buffer's
    /// presentation time. This property may return cm::Time::invalid.
    #[cfg(feature = "cm")]
    #[objc::msg_send(time)]
    pub fn time(&self) -> cm::Time;

    /// The media duration associated with this metadata object.
    ///
    /// The value of this property is a cm::Time representing the duration
    /// of the metadata object. If this metadata object originates from a cm::SampleBuffer,
    /// its duration matches the sample buffer's duration.
    /// This property may return cm::Time::invalid.
    #[cfg(feature = "cm")]
    #[objc::msg_send(duration)]
    pub fn duration(&self) -> cm::Time;

    /// An identifier for the metadata object.
    ///
    /// Clients inspecting a collection of metadata objects can use this property to filter objects
    /// with a matching type.
    #[objc::msg_send(type)]
    pub fn obj_type(&self) -> &Type;

    /// A number associated with object groups (e.g., face and body) that is unique for each physical object
    /// (e.g., a person whom the face and body belong to).
    ///
    /// The value of this property is an NSInteger indicating the unique identifier to combine objects (for instance,
    /// face and body) into groups (a physical person). A human body and face for the same person will have the same group ID.
    /// It is set to -1 when it's invalid or not available. When it's set to a value of >=0, it is unique across all object groups.
    #[objc::msg_send(groupID)]
    #[api::available(macos = 26.0, ios = 26.0, maccatalyst = 26.0, tvos = 26.0)]
    pub fn group_id(&self) -> isize;

    /// A unique identifier for each detected object type (face, body, hands, heads and salient objects).
    ///
    /// Defaults to a value of -1 when it is invalid or not available. When a new object enters the picture,
    /// it is assigned a new unique identifier. obj_idss are not re-used as objects leave the picture and new ones enter.
    ///  Objects that leave the picture then re-enter are assigned a new objectID.
    #[objc::msg_send(objectID)]
    #[api::available(macos = 26.0, ios = 26.0, maccatalyst = 26.0, tvos = 26.0)]
    pub fn obj_id(&self) -> isize;
}

/// AVMetadataObjectCinematicVideoSupport
impl Obj {
    #[objc::msg_send(cinematicVideoFocusMode)]
    #[api::available(macos = 26.0, ios = 26.0, maccatalyst = 26.0, tvos = 26.0)]
    pub fn cinematic_video_focus_mode(&self) -> av::CaptureCinematicVideoFocusMode;

    #[objc::msg_send(isFixedFocus)]
    #[api::available(macos = 26.0, ios = 26.0, maccatalyst = 26.0, tvos = 26.0)]
    pub fn is_fixed_focus(&self) -> bool;
}

define_obj_type!(
    #[doc(alias = "AVMetadataBodyObject")]
    pub BodyObj(Obj));

impl BodyObj {
    #[objc::msg_send(bodyID)]
    pub fn body_id(&self) -> isize;
}

define_obj_type!(
    #[doc(alias = "AVMetadataCatBodyObject")]
    pub CatBodyObj(BodyObj)
);
define_obj_type!(
    #[doc(alias = "AVMetadataCatHeadObject")]
    pub CatHeadObj(Obj)
);

define_obj_type!(
    #[doc(alias = "AVMetadataDogBodyObject")]
    pub DogBodyObj(BodyObj)
);

define_obj_type!(
    #[doc(alias = "AVMetadataDogHeadObject")]
    pub DogHeadObj(Obj)
);

define_obj_type!(
    #[doc(alias = "AVMetadataHumanBodyObject")]
    pub HumanBodyObj(BodyObj)
);

define_obj_type!(
    #[doc(alias = "AVMetadataHumanFullBodyObject")]
    pub HumanFullBodyObj(BodyObj)
);

define_obj_type!(
    #[doc(alias = "AVMetadataFaceObject")]
    pub FaceObj(Obj)
);

define_obj_type!(
    #[doc(alias = "AVMetadataMachineReadableCodeObject")]
    pub MachineReadableCodeObj(Obj)
);

define_obj_type!(
    #[doc(alias = "AVMetadataSalientObject")]
    pub SalientObj(Obj)
);

impl SalientObj {
    #[objc::msg_send(objectID)]
    pub fn obj_id(&self) -> isize;
}

impl FaceObj {
    /// A unique number associated with the receiver.
    ///
    /// The value of this property is an isize indicating the unique identifier of this face in the picture.
    /// When a new face enters the picture, it is assigned a new unique identifier. face_ids are not re-used as faces
    /// leave the picture and new ones enter. Faces that leave the picture then re-enter are assigned a new face_id.
    #[objc::msg_send(faceID)]
    pub fn face_id(&self) -> isize;

    /// The roll angle of the face in degrees.
    ///
    /// The value of this property is a cg::Float indicating the face's angle of roll (or tilt) in degrees.
    /// A value of 0.0 indicates that the face is level in the picture. If -has_roll_angle returns false, then reading this property throws
    /// an ns::GenericException.
    #[objc::msg_send(hasRollAngle)]
    pub fn has_roll_angle(&self) -> bool;

    #[objc::msg_send(rollAngle)]
    pub unsafe fn roll_angle_throws(&self) -> cg::Float;

    /// The roll angle of the face in degrees.
    #[inline]
    pub fn roll_angle(&self) -> Option<cg::Float> {
        if self.has_roll_angle() {
            Some(unsafe { self.roll_angle_throws() })
        } else {
            None
        }
    }
    #[objc::msg_send(hasYawAngle)]
    pub fn has_yaw_angle(&self) -> bool;

    /// The yaw angle of the face in degrees.
    ///
    /// The value of this property is a cg::Float indicating the face's angle of yaw (or turn) in degrees.
    /// A value of 0.0 indicates that the face is straight on in the picture.
    /// If has_yaw_angle() returns false, then reading this property throws an ns::GenericException.
    #[objc::msg_send(yawAngle)]
    pub unsafe fn yaw_angle_throws(&self) -> cg::Float;

    /// The yaw angle of the face in degrees.
    #[inline]
    pub fn yaw_angle(&self) -> Option<cg::Float> {
        if self.has_yaw_angle() {
            Some(unsafe { self.yaw_angle_throws() })
        } else {
            None
        }
    }
}

impl MachineReadableCodeObj {
    /// The points defining the (X,Y) locations of the corners of the machine-readable code.
    #[objc::msg_send(corners)]
    pub fn corners(&self) -> arc::R<ns::Dictionary<ns::String, ns::Id>>;

    /// Returns the receiver's errorCorrectedData decoded into a human-readable string.
    #[objc::msg_send(stringValue)]
    pub fn string_value(&self) -> Option<arc::R<ns::String>>;
}

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

/// AVMetadataMachineReadableCodeDescriptor
#[cfg(feature = "ci")]
impl MachineReadableCodeObj {
    /// An abstract representation of a machine readable code's symbol attributes.
    ///
    /// The value may be None if an abstract representation of a machine readable
    /// code object is not defined for the code type or could not be detected.
    #[objc::msg_send(descriptor)]
    pub fn descriptor(&self) -> Option<arc::R<ci::BarcodeDesc>>;
}