objc2_image_io/generated/
CGImageMetadata.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9use objc2_core_foundation::*;
10
11use crate::*;
12
13/// an immutable container for CGImageMetadataTags
14///
15/// See also [Apple's documentation](https://developer.apple.com/documentation/imageio/cgimagemetadata?language=objc)
16#[doc(alias = "CGImageMetadataRef")]
17#[repr(C)]
18pub struct CGImageMetadata {
19    inner: [u8; 0],
20    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
21}
22
23cf_type!(
24    unsafe impl CGImageMetadata {}
25);
26#[cfg(feature = "objc2")]
27cf_objc2_type!(
28    unsafe impl RefEncode<"CGImageMetadata"> for CGImageMetadata {}
29);
30
31unsafe impl ConcreteType for CGImageMetadata {
32    /// *!
33    ///
34    ///
35    ///
36    /// Gets the type identifier for the CGImageMetadata opaque type
37    ///
38    /// Returns: the type identifier for the CGImageMetadata opaque type
39    #[doc(alias = "CGImageMetadataGetTypeID")]
40    #[inline]
41    fn type_id() -> CFTypeID {
42        extern "C-unwind" {
43            fn CGImageMetadataGetTypeID() -> CFTypeID;
44        }
45        unsafe { CGImageMetadataGetTypeID() }
46    }
47}
48
49/// a mutable container for CGImageMetadataTags
50///
51/// A CGMutableImageMetadataRef can be used in any function that
52/// accepts a CGImageMetadataRef.
53///
54/// See also [Apple's documentation](https://developer.apple.com/documentation/imageio/cgmutableimagemetadata?language=objc)
55#[doc(alias = "CGMutableImageMetadataRef")]
56#[repr(C)]
57pub struct CGMutableImageMetadata {
58    inner: [u8; 0],
59    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
60}
61
62cf_type!(
63    unsafe impl CGMutableImageMetadata: CGImageMetadata {}
64);
65#[cfg(feature = "objc2")]
66cf_objc2_type!(
67    unsafe impl RefEncode<"CGImageMetadata"> for CGMutableImageMetadata {}
68);
69
70impl CGMutableImageMetadata {
71    /// Creates an empty CGMutableImageMetadataRef
72    #[doc(alias = "CGImageMetadataCreateMutable")]
73    #[inline]
74    pub unsafe fn new() -> CFRetained<CGMutableImageMetadata> {
75        extern "C-unwind" {
76            fn CGImageMetadataCreateMutable() -> Option<NonNull<CGMutableImageMetadata>>;
77        }
78        let ret = unsafe { CGImageMetadataCreateMutable() };
79        let ret =
80            ret.expect("function was marked as returning non-null, but actually returned NULL");
81        unsafe { CFRetained::from_raw(ret) }
82    }
83
84    /// Creates a deep mutable copy of another CGImageMetadataRef
85    ///
86    /// Before modifying an immutable CGImageMetadataRef (such as metadata
87    /// from CGImageSourceCopyMetadataAtIndex) you must first make a copy.
88    /// This function makes a deep copy of all CGImageMetadataTags and their values.
89    #[doc(alias = "CGImageMetadataCreateMutableCopy")]
90    #[inline]
91    pub unsafe fn new_copy(
92        metadata: &CGImageMetadata,
93    ) -> Option<CFRetained<CGMutableImageMetadata>> {
94        extern "C-unwind" {
95            fn CGImageMetadataCreateMutableCopy(
96                metadata: &CGImageMetadata,
97            ) -> Option<NonNull<CGMutableImageMetadata>>;
98        }
99        let ret = unsafe { CGImageMetadataCreateMutableCopy(metadata) };
100        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
101    }
102}
103
104/// an individual metadata tag
105///
106/// A CGImageMetadataTag encapsulates an EXIF, IPTC, or XMP property.
107/// All tags contain a namespace, prefix, name, type, and value. Please see
108///
109/// ```text
110///  CGImageMetadataTagCreate
111/// ```
112///
113/// for more details.
114///
115/// See also [Apple's documentation](https://developer.apple.com/documentation/imageio/cgimagemetadatatag?language=objc)
116#[doc(alias = "CGImageMetadataTagRef")]
117#[repr(C)]
118pub struct CGImageMetadataTag {
119    inner: [u8; 0],
120    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
121}
122
123cf_type!(
124    unsafe impl CGImageMetadataTag {}
125);
126#[cfg(feature = "objc2")]
127cf_objc2_type!(
128    unsafe impl RefEncode<"CGImageMetadataTag"> for CGImageMetadataTag {}
129);
130
131unsafe impl ConcreteType for CGImageMetadataTag {
132    /// *!
133    ///
134    ///
135    ///
136    /// Gets the type identifier for the CGImageMetadataTag opaque type
137    ///
138    /// Returns: the type identifier for the CGImageMetadataTagGetTypeID opaque type
139    #[doc(alias = "CGImageMetadataTagGetTypeID")]
140    #[inline]
141    fn type_id() -> CFTypeID {
142        extern "C-unwind" {
143            fn CGImageMetadataTagGetTypeID() -> CFTypeID;
144        }
145        unsafe { CGImageMetadataTagGetTypeID() }
146    }
147}
148
149extern "C" {
150    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagemetadatanamespaceexif?language=objc)
151    pub static kCGImageMetadataNamespaceExif: &'static CFString;
152}
153
154extern "C" {
155    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagemetadatanamespaceexifaux?language=objc)
156    pub static kCGImageMetadataNamespaceExifAux: &'static CFString;
157}
158
159extern "C" {
160    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagemetadatanamespaceexifex?language=objc)
161    pub static kCGImageMetadataNamespaceExifEX: &'static CFString;
162}
163
164extern "C" {
165    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagemetadatanamespacedublincore?language=objc)
166    pub static kCGImageMetadataNamespaceDublinCore: &'static CFString;
167}
168
169extern "C" {
170    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagemetadatanamespaceiptccore?language=objc)
171    pub static kCGImageMetadataNamespaceIPTCCore: &'static CFString;
172}
173
174extern "C" {
175    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagemetadatanamespaceiptcextension?language=objc)
176    pub static kCGImageMetadataNamespaceIPTCExtension: &'static CFString;
177}
178
179extern "C" {
180    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagemetadatanamespacephotoshop?language=objc)
181    pub static kCGImageMetadataNamespacePhotoshop: &'static CFString;
182}
183
184extern "C" {
185    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagemetadatanamespacetiff?language=objc)
186    pub static kCGImageMetadataNamespaceTIFF: &'static CFString;
187}
188
189extern "C" {
190    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagemetadatanamespacexmpbasic?language=objc)
191    pub static kCGImageMetadataNamespaceXMPBasic: &'static CFString;
192}
193
194extern "C" {
195    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagemetadatanamespacexmprights?language=objc)
196    pub static kCGImageMetadataNamespaceXMPRights: &'static CFString;
197}
198
199extern "C" {
200    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagemetadataprefixexif?language=objc)
201    pub static kCGImageMetadataPrefixExif: &'static CFString;
202}
203
204extern "C" {
205    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagemetadataprefixexifaux?language=objc)
206    pub static kCGImageMetadataPrefixExifAux: &'static CFString;
207}
208
209extern "C" {
210    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagemetadataprefixexifex?language=objc)
211    pub static kCGImageMetadataPrefixExifEX: &'static CFString;
212}
213
214extern "C" {
215    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagemetadataprefixdublincore?language=objc)
216    pub static kCGImageMetadataPrefixDublinCore: &'static CFString;
217}
218
219extern "C" {
220    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagemetadataprefixiptccore?language=objc)
221    pub static kCGImageMetadataPrefixIPTCCore: &'static CFString;
222}
223
224extern "C" {
225    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagemetadataprefixiptcextension?language=objc)
226    pub static kCGImageMetadataPrefixIPTCExtension: &'static CFString;
227}
228
229extern "C" {
230    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagemetadataprefixphotoshop?language=objc)
231    pub static kCGImageMetadataPrefixPhotoshop: &'static CFString;
232}
233
234extern "C" {
235    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagemetadataprefixtiff?language=objc)
236    pub static kCGImageMetadataPrefixTIFF: &'static CFString;
237}
238
239extern "C" {
240    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagemetadataprefixxmpbasic?language=objc)
241    pub static kCGImageMetadataPrefixXMPBasic: &'static CFString;
242}
243
244extern "C" {
245    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagemetadataprefixxmprights?language=objc)
246    pub static kCGImageMetadataPrefixXMPRights: &'static CFString;
247}
248
249/// The XMP type for a CGImageMetadataTag
250///
251/// CGImageMetadataType defines a list of constants used to indicate
252/// the type for a CGImageMetadataTag. If you are reading metadata, use the type
253/// to determine how to interpret the CGImageMetadataTag's value. If you are
254/// creating a CGImageMetadataTag, use the type to specify how the tag
255/// should be serialized in XMP. String types have CFStringRef values, array
256/// types have CFArray values, and structure types have CFDictionary values.
257///
258/// CFType of the tag's value. This is only used when creating a new
259/// CGImageMetadataTag - no existing tags should have this value. CFString
260/// defaults to kCGImageMetadataTypeString, CFArray defaults to
261/// kCGImageMetadataTypeArrayOrdered, and CFDictionary defaults to
262/// kCGImageMetadataTypeStructure.
263///
264/// values will be converted to a string.
265///
266/// Serialized in XMP as
267/// <rdf
268/// :Bag>.
269///
270/// Serialized in XMP as
271/// <rdf
272/// :Seq>.
273///
274/// are alternates for the same value. Serialized in XMP as
275/// <rdf
276/// :Alt>.
277///
278/// where all elements are different localized strings for the same value.
279/// Serialized in XMP as an alternate array of strings with xml:lang qualifiers.
280///
281/// array elements, fields of a structure may belong to different namespaces.
282///
283/// See also [Apple's documentation](https://developer.apple.com/documentation/imageio/cgimagemetadatatype?language=objc)
284// NS_ENUM
285#[repr(transparent)]
286#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
287pub struct CGImageMetadataType(pub i32);
288impl CGImageMetadataType {
289    #[doc(alias = "kCGImageMetadataTypeInvalid")]
290    pub const Invalid: Self = Self(-1);
291    #[doc(alias = "kCGImageMetadataTypeDefault")]
292    pub const Default: Self = Self(0);
293    #[doc(alias = "kCGImageMetadataTypeString")]
294    pub const String: Self = Self(1);
295    #[doc(alias = "kCGImageMetadataTypeArrayUnordered")]
296    pub const ArrayUnordered: Self = Self(2);
297    #[doc(alias = "kCGImageMetadataTypeArrayOrdered")]
298    pub const ArrayOrdered: Self = Self(3);
299    #[doc(alias = "kCGImageMetadataTypeAlternateArray")]
300    pub const AlternateArray: Self = Self(4);
301    #[doc(alias = "kCGImageMetadataTypeAlternateText")]
302    pub const AlternateText: Self = Self(5);
303    #[doc(alias = "kCGImageMetadataTypeStructure")]
304    pub const Structure: Self = Self(6);
305}
306
307#[cfg(feature = "objc2")]
308unsafe impl Encode for CGImageMetadataType {
309    const ENCODING: Encoding = i32::ENCODING;
310}
311
312#[cfg(feature = "objc2")]
313unsafe impl RefEncode for CGImageMetadataType {
314    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
315}
316
317impl CGImageMetadataTag {
318    /// Creates a new CGImageMetadataTag
319    ///
320    /// Parameter `xmlns`: The namespace for the tag. The value can be a common XMP namespace
321    /// defined above, such as kCGImageMetadataNamespaceExif, or a CFString with a
322    /// custom namespace URI. Custom namespaces must be a valid XML namespace. By
323    /// convention, namespaces should end with either '/' or '#'. For example, exif
324    /// uses the namespace "http://ns.adobe.com/exif/1.0/".
325    ///
326    /// Parameter `prefix`: An abbreviation for the XML namespace. The value can be NULL if
327    /// the namespace is defined as a constant. Custom prefixes must be a valid XML
328    /// name. For example, the prefix used for "http://ns.adobe.com/exif/1.0/" is "exif".
329    /// The XMP serialization of the tag will use the prefix. Prefixes are also
330    /// important for path-based CGImageMetadata functions, such as
331    ///
332    /// ```text
333    ///  CGImageMetadataCopyStringValueWithPath
334    /// ```
335    ///
336    /// or
337    ///
338    /// ```text
339    ///  CGImageMetadataSetValueWithPath
340    /// ```
341    ///
342    /// .
343    ///
344    /// Parameter `name`: The name of the tag. It must be a valid XMP name.
345    ///
346    /// Parameter `type`: The type of the tag's value. Must be a constant from
347    ///
348    /// ```text
349    ///  
350    ///  CGImageMetadataType
351    /// ```
352    ///
353    /// .
354    ///
355    /// Parameter `value`: The value of the tag. Allowable CFTypes include CFStringRef,
356    /// CFNumberRef, CFBooleanRef, CFArrayRef, and CFDictionaryRef. The CFType of 'value'
357    /// must correspond to the 'type'. The elements of a CFArray must be either a
358    /// CFStringRef or CGImageMetadataTagRef. The keys of a CFDictionary must be
359    /// CFStringRefs with valid XMP names. The values of a CFDictionary must be either
360    /// CFStringRefs or CGImageMetadataTagRefs. A shallow copy of the value is stored
361    /// in the tag. Therefore, modifying a mutable value after the tag is created
362    /// will not affect the tag's value.
363    ///
364    /// Returns: Returns a pointer to a new CGImageMetadataTag. Returns NULL if a tag
365    /// could not be created with the specified parameters.
366    ///
367    /// # Safety
368    ///
369    /// `value` should be of the correct type.
370    #[doc(alias = "CGImageMetadataTagCreate")]
371    #[inline]
372    pub unsafe fn new(
373        xmlns: &CFString,
374        prefix: Option<&CFString>,
375        name: &CFString,
376        r#type: CGImageMetadataType,
377        value: &CFType,
378    ) -> Option<CFRetained<CGImageMetadataTag>> {
379        extern "C-unwind" {
380            fn CGImageMetadataTagCreate(
381                xmlns: &CFString,
382                prefix: Option<&CFString>,
383                name: &CFString,
384                r#type: CGImageMetadataType,
385                value: &CFType,
386            ) -> Option<NonNull<CGImageMetadataTag>>;
387        }
388        let ret = unsafe { CGImageMetadataTagCreate(xmlns, prefix, name, r#type, value) };
389        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
390    }
391
392    /// *!
393    ///
394    ///
395    ///
396    /// Returns a copy of the tag's namespace
397    #[doc(alias = "CGImageMetadataTagCopyNamespace")]
398    #[inline]
399    pub unsafe fn namespace(&self) -> Option<CFRetained<CFString>> {
400        extern "C-unwind" {
401            fn CGImageMetadataTagCopyNamespace(
402                tag: &CGImageMetadataTag,
403            ) -> Option<NonNull<CFString>>;
404        }
405        let ret = unsafe { CGImageMetadataTagCopyNamespace(self) };
406        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
407    }
408
409    /// Returns a copy of the tag's prefix
410    #[doc(alias = "CGImageMetadataTagCopyPrefix")]
411    #[inline]
412    pub unsafe fn prefix(&self) -> Option<CFRetained<CFString>> {
413        extern "C-unwind" {
414            fn CGImageMetadataTagCopyPrefix(tag: &CGImageMetadataTag) -> Option<NonNull<CFString>>;
415        }
416        let ret = unsafe { CGImageMetadataTagCopyPrefix(self) };
417        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
418    }
419
420    /// Returns a copy of the tag's name
421    #[doc(alias = "CGImageMetadataTagCopyName")]
422    #[inline]
423    pub unsafe fn name(&self) -> Option<CFRetained<CFString>> {
424        extern "C-unwind" {
425            fn CGImageMetadataTagCopyName(tag: &CGImageMetadataTag) -> Option<NonNull<CFString>>;
426        }
427        let ret = unsafe { CGImageMetadataTagCopyName(self) };
428        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
429    }
430
431    /// Returns a shallow copy of the tag's value
432    ///
433    /// This function should only be used to read the tag's value.
434    /// CGImageMetadataCopyTagWithPath returns a copy of the tag (including a copy of
435    /// the tag's value). Therefore mutating a tag's value returned from this function
436    /// may not actually mutate the value in the CGImageMetadata. It is recommended
437    /// to create a new tag followed by CGImageMetadataSetTagWithPath, or use
438    /// CGImageMetadataSetValueWithPath to mutate a metadata value.
439    #[doc(alias = "CGImageMetadataTagCopyValue")]
440    #[inline]
441    pub unsafe fn value(&self) -> Option<CFRetained<CFType>> {
442        extern "C-unwind" {
443            fn CGImageMetadataTagCopyValue(tag: &CGImageMetadataTag) -> Option<NonNull<CFType>>;
444        }
445        let ret = unsafe { CGImageMetadataTagCopyValue(self) };
446        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
447    }
448
449    /// Get the type of the CGImageMetadataTag
450    ///
451    /// Returns: Returns a CGImageMetadataType constant for the CGImageMetadataTag.
452    /// This is primarily used to determine how to interpret the tag's value.
453    #[doc(alias = "CGImageMetadataTagGetType")]
454    #[inline]
455    pub unsafe fn r#type(&self) -> CGImageMetadataType {
456        extern "C-unwind" {
457            fn CGImageMetadataTagGetType(tag: &CGImageMetadataTag) -> CGImageMetadataType;
458        }
459        unsafe { CGImageMetadataTagGetType(self) }
460    }
461
462    /// Return a copy of the tag's qualifiers
463    ///
464    /// XMP allows properties to contain supplemental properties called
465    /// qualifiers. Qualifiers are themselves CGImageMetadataTags with their own
466    /// namespace, prefix, name, and value. A common use is the xml:lang qualifier
467    /// for elements of an alternate-text array.
468    ///
469    /// Returns: Returns a copy of the array of qualifiers. Elements of the array are
470    /// CGImageMetadataTags. Returns NULL if the tag does not have any qualifiers.
471    /// The copy is shallow, the qualifiers are not deep copied.
472    #[doc(alias = "CGImageMetadataTagCopyQualifiers")]
473    #[inline]
474    pub unsafe fn qualifiers(&self) -> Option<CFRetained<CFArray>> {
475        extern "C-unwind" {
476            fn CGImageMetadataTagCopyQualifiers(
477                tag: &CGImageMetadataTag,
478            ) -> Option<NonNull<CFArray>>;
479        }
480        let ret = unsafe { CGImageMetadataTagCopyQualifiers(self) };
481        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
482    }
483}
484
485impl CGImageMetadata {
486    /// *!
487    ///
488    ///
489    ///
490    /// Obtain an array of tags from a CGImageMetadataRef
491    ///
492    /// Returns: Returns an array with a shallow copy of all top-level
493    /// CGImageMetadataTagRefs in a CGImageMetadataRef.
494    #[doc(alias = "CGImageMetadataCopyTags")]
495    #[inline]
496    pub unsafe fn tags(&self) -> Option<CFRetained<CFArray>> {
497        extern "C-unwind" {
498            fn CGImageMetadataCopyTags(metadata: &CGImageMetadata) -> Option<NonNull<CFArray>>;
499        }
500        let ret = unsafe { CGImageMetadataCopyTags(self) };
501        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
502    }
503
504    /// Searches for a specific CGImageMetadataTag in a CGImageMetadataRef
505    ///
506    /// This is the primary function for clients to obtain specific
507    /// metadata properties from an image. The 'path' mechanism provides a way to
508    /// access both simple top-level properties, such as Date
509    /// &
510    /// Time, or complex
511    /// deeply-nested properties with ease.
512    ///
513    /// Parameter `metadata`: A collection of metadata tags.
514    ///
515    /// Parameter `parent`: A parent tag. If NULL, the path is relative to the root of the
516    /// CGImageMetadataRef (i.e. it is not a child of another property). If the parent
517    /// is provided, the effective path will be the concatenation of the parent's path
518    /// and the 'path' parameter. This is useful for accessing array elements or
519    /// structure fields inside nested tags.
520    ///
521    /// Parameter `path`: A string representing a path to the desired tag. Paths consist of
522    /// a tag prefix (i.e. "exif") joined with a tag name (i.e. "Flash") by a colon
523    /// (":"), such as CFSTR("exif:Flash").
524    /// Elements of ordered and unordered arrays are accessed via 0-based indices inside square [] brackets.
525    /// Elements of alternate-text arrays are accessed by an RFC 3066 language code inside square [] brackets.
526    /// Fields of a structure are delimited by a period, '.'.
527    /// Qualifiers are delimited by the '?' character. Only tags with string values (kCGImageMetadataTypeString)
528    /// are allowed to have qualifiers - arrays and structures may not contain qualifiers.
529    ///
530    /// If parent is NULL, a prefix must be specified for the first tag. Prefixes for
531    /// all subsequent tags are optional. If unspecified, the prefix is
532    /// inherented from the nearest parent tag with a prefix. Custom prefixes must be
533    /// registered using
534    ///
535    /// ```text
536    ///  CGImageMetadataRegisterNamespaceForPrefix
537    /// ```
538    ///
539    /// prior to use
540    /// in any path-based functions.
541    ///
542    /// Examples:
543    /// <ul>
544    /// <li>
545    /// 'path' = CFSTR("xmp:CreateDate")
546    /// </li>
547    /// <li>
548    /// 'path' = CFSTR("exif:Flash.Fired")
549    /// </li>
550    /// <li>
551    /// 'parent' = tag at path CFSTR("exif:Flash"), path = CFSTR("exif:Fired") (equivilent to previous)
552    /// </li>
553    /// <li>
554    /// 'path' = CFSTR("exif:Flash.RedEyeMode")
555    /// </li>
556    /// <li>
557    /// 'path' = CFSTR("dc:title")
558    /// </li>
559    /// <li>
560    /// 'path' = CFSTR("dc:subject")
561    /// </li>
562    /// <li>
563    /// 'path' = CFSTR("dc:subject[2]")
564    /// </li>
565    /// <li>
566    /// 'parent' = tag at path CFSTR("dc:subject"), path = CFSTR("[2]") (equivilent to previous)
567    /// </li>
568    /// <li>
569    /// 'path' = CFSTR("dc:description[x-default])"
570    /// </li>
571    /// <li>
572    /// 'path' = CFSTR("dc.description[de])"
573    /// </li>
574    /// <li>
575    /// 'path' = CFSTR("dc.description[fr])"
576    /// </li>
577    /// <li>
578    /// 'path' = CFSTR("foo:product)"
579    /// </li>
580    /// <li>
581    /// 'path' = CFSTR("foo:product?bar:manufacturer)"
582    /// </li>
583    /// </ul>
584    ///
585    /// Returns: Returns a copy of CGImageMetadataTag matching 'path', or NULL if no
586    /// match is found. The copy of the tag's value is shallow. Tags
587    /// copied from an immutable CGImageMetadataRef are also immutable. Because this
588    /// function returns a copy of the tag's value, any modification of the tag's
589    /// value must be followed by a CGImageMetadataSetTagWithPath to commit the
590    /// change to the metadata container.
591    #[doc(alias = "CGImageMetadataCopyTagWithPath")]
592    #[inline]
593    pub unsafe fn tag_with_path(
594        &self,
595        parent: Option<&CGImageMetadataTag>,
596        path: &CFString,
597    ) -> Option<CFRetained<CGImageMetadataTag>> {
598        extern "C-unwind" {
599            fn CGImageMetadataCopyTagWithPath(
600                metadata: &CGImageMetadata,
601                parent: Option<&CGImageMetadataTag>,
602                path: &CFString,
603            ) -> Option<NonNull<CGImageMetadataTag>>;
604        }
605        let ret = unsafe { CGImageMetadataCopyTagWithPath(self, parent, path) };
606        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
607    }
608
609    /// Searches for a specific tag in a CGImageMetadataRef and returns its
610    /// string value.
611    ///
612    /// This is a convenience method for searching for a tag at path and
613    /// extracting the string value.
614    ///
615    /// Parameter `metadata`: A collection of metadata tags.
616    ///
617    /// Parameter `parent`: A parent tag. If NULL, the path is relative to the root of the
618    /// CGImageMetadataRef (i.e. it is not a child of another property).
619    ///
620    /// Parameter `path`: A string with the path to the desired tag. Please consult
621    /// the documentation of
622    ///
623    /// ```text
624    ///  CGImageMetadataCopyTagWithPath
625    /// ```
626    ///
627    /// for
628    /// information about path syntax.
629    ///
630    /// Returns: Returns a string from a CGImageMetadataTag located at 'path'. The
631    /// tag must be of type kCGImageMetadataTypeString or kCGImageMetadataTypeAlternateText.
632    /// For AlternateText tags, the element with the "x-default" language qualifier
633    /// will be returned. For other types, NULL will be returned.
634    #[doc(alias = "CGImageMetadataCopyStringValueWithPath")]
635    #[inline]
636    pub unsafe fn string_value_with_path(
637        &self,
638        parent: Option<&CGImageMetadataTag>,
639        path: &CFString,
640    ) -> Option<CFRetained<CFString>> {
641        extern "C-unwind" {
642            fn CGImageMetadataCopyStringValueWithPath(
643                metadata: &CGImageMetadata,
644                parent: Option<&CGImageMetadataTag>,
645                path: &CFString,
646            ) -> Option<NonNull<CFString>>;
647        }
648        let ret = unsafe { CGImageMetadataCopyStringValueWithPath(self, parent, path) };
649        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
650    }
651}
652
653impl CGMutableImageMetadata {
654    /// *!
655    ///
656    ///
657    ///
658    /// Associates an XMP namespace URI with a prefix string.
659    ///
660    /// This allows ImageIO to create custom metadata when it encounters
661    /// an unrecognized prefix in a path (see CGImageMetadataCopyTagWithPath for more
662    /// information about path syntax). A namespace must be registered before it can
663    /// be used to add custom metadata. All namespaces found in the image's metadata,
664    /// or defined as a constant above, will be pre-registered. Namespaces and
665    /// prefixes must be unique.
666    ///
667    /// Returns: Returns true if successful. Returns false and sets 'err' if an error
668    /// or conflict occurs.
669    ///
670    /// # Safety
671    ///
672    /// `err` must be a valid pointer or null.
673    #[doc(alias = "CGImageMetadataRegisterNamespaceForPrefix")]
674    #[inline]
675    pub unsafe fn register_namespace_for_prefix(
676        &self,
677        xmlns: &CFString,
678        prefix: &CFString,
679        err: *mut *mut CFError,
680    ) -> bool {
681        extern "C-unwind" {
682            fn CGImageMetadataRegisterNamespaceForPrefix(
683                metadata: &CGMutableImageMetadata,
684                xmlns: &CFString,
685                prefix: &CFString,
686                err: *mut *mut CFError,
687            ) -> bool;
688        }
689        unsafe { CGImageMetadataRegisterNamespaceForPrefix(self, xmlns, prefix, err) }
690    }
691
692    /// Sets the tag at a specific path in a CGMutableImageMetadata container or a parent tag
693    ///
694    /// This is the primary function for adding new metadata tags to a
695    /// metadata container, or updating existing tags. All tags required to reach
696    /// the final tag (at the end of the path) will be created, if needed. Tags will
697    /// created with default types (ordered arrays). Creating tags will fail if a
698    /// prefix is encountered that has not been registered. Use
699    ///
700    /// ```text
701    ///  CGImageMetadataRegisterNamespaceForPrefix
702    /// ```
703    ///
704    /// to associate a prefix
705    /// with a namespace prior to using a path-based CGImageMetadata function.
706    /// Note that if a parent tag is provided,
707    /// the children of that tag reference will be modified, which may be a different
708    /// reference from the tag stored in the metadata container. Since tags are normally
709    /// obtained as a copy, it is typically neccesary to use CGImageMetadataSetTagWithPath
710    /// to commit the changed parent object back to the metadata container (using
711    /// the parent's path and NULL for the parent).
712    ///
713    /// Parameter `metadata`: A mutable collection of metadata tags.
714    /// Use
715    ///
716    /// ```text
717    ///  CGImageMetadataCreateMutableCopy
718    /// ```
719    ///
720    /// or
721    ///
722    /// ```text
723    ///  CGImageMetadataCreateMutable
724    /// ```
725    ///
726    /// to obtain a mutable metadata container.
727    ///
728    /// Parameter `parent`: A parent tag. If NULL, the path is relative to the root of the
729    /// CGImageMetadataRef (i.e. it is not a child of another property).
730    /// Note that if a parent tag is provided,
731    /// the children of that tag reference will be modified, which may be a different
732    /// reference from the tag stored in the metadata container. Since tags are normally
733    /// obtained as a copy, it is typically neccesary to use CGImageMetadataSetTagWithPath
734    /// to commit the changed parent object back to the metadata container (using
735    /// the parent's path and NULL for the parent).
736    ///
737    /// Parameter `path`: A string with the path to the desired tag. Please consult
738    /// the documentation of
739    ///
740    /// ```text
741    ///  CGImageMetadataCopyTagWithPath
742    /// ```
743    ///
744    /// for
745    /// information about path syntax.
746    ///
747    /// Parameter `tag`: The CGImageMetadataTag to be added to the metadata. The tag
748    /// will be retained.
749    ///
750    /// Returns: Returns true if successful, false otherwise.
751    #[doc(alias = "CGImageMetadataSetTagWithPath")]
752    #[inline]
753    pub unsafe fn set_tag_with_path(
754        &self,
755        parent: Option<&CGImageMetadataTag>,
756        path: &CFString,
757        tag: &CGImageMetadataTag,
758    ) -> bool {
759        extern "C-unwind" {
760            fn CGImageMetadataSetTagWithPath(
761                metadata: &CGMutableImageMetadata,
762                parent: Option<&CGImageMetadataTag>,
763                path: &CFString,
764                tag: &CGImageMetadataTag,
765            ) -> bool;
766        }
767        unsafe { CGImageMetadataSetTagWithPath(self, parent, path, tag) }
768    }
769
770    /// Sets the value of the tag at a specific path in a CGMutableImageMetadataRef container or a parent tag
771    ///
772    /// This function is used to add new metadata values to a
773    /// metadata container, or update existing tag values. All tags required to reach
774    /// the final tag (at the end of the path) are created, if needed. Tags are
775    /// created with default types (i.e. arrays will be ordered). Creating tags will
776    /// fail if a prefix is encountered that has not been registered. Use
777    ///
778    /// ```text
779    ///  CGImageMetadataRegisterNamespaceForPrefix
780    /// ```
781    ///
782    /// to associate a prefix
783    /// with a namespace prior to using a path-based CGImageMetadata function.
784    ///
785    /// Examples
786    /// <ul>
787    /// <li>
788    /// 'path' = CFSTR("xmp:CreateDate"), 'value' = CFSTR("2011-09-20T14:54:47-08:00")
789    /// </li>
790    /// <li>
791    /// 'path' = CFSTR("dc:subject[0]"), 'value' = CFSTR("San Francisco")
792    /// </li>
793    /// <li>
794    /// 'path' = CFSTR("dc:subject[1]"), 'value' = CFSTR("Golden Gate Bridge")
795    /// </li>
796    /// <li>
797    /// 'path' = CFSTR("dc:description[en]") 'value' = CFSTR("my image description")
798    /// </li>
799    /// <li>
800    /// 'path' = CFSTR("dc:description[de]") 'value' = CFSTR("meine bildbeschreibung")
801    /// </li>
802    /// </ul>
803    /// Note that if a parent tag is provided,
804    /// the children of that tag reference will be modified, which may be a different
805    /// reference from the tag stored in the metadata container. Since tags are normally
806    /// obtained as a copy, it is typically neccesary to use CGImageMetadataSetTagWithPath
807    /// to commit the changed parent object back to the metadata container (using
808    /// the parent's path and NULL for the parent).
809    ///
810    /// Parameter `metadata`: A mutable collection of metadata tags.
811    /// Use
812    ///
813    /// ```text
814    ///  CGImageMetadataCreateMutableCopy
815    /// ```
816    ///
817    /// or
818    ///
819    /// ```text
820    ///  CGImageMetadataCreateMutable
821    /// ```
822    ///
823    /// to obtain a mutable metadata container.
824    ///
825    /// Parameter `parent`: A parent tag. If NULL, the path is relative to the root of the
826    /// CGImageMetadataRef (i.e. it is not a child of another property).
827    ///
828    /// Parameter `path`: A string with the path to the desired tag. Please consult
829    /// the documentation of
830    ///
831    /// ```text
832    ///  CGImageMetadataCopyTagWithPath
833    /// ```
834    ///
835    /// for
836    /// information about path syntax.
837    ///
838    /// Parameter `value`: The value to be added to the CGImageMetadataTag matching the path.
839    /// The tag will be retained. The restrictions for the value are the same as in
840    ///
841    /// ```text
842    ///  CGImageMetadataTagCreate
843    /// ```
844    ///
845    /// .
846    ///
847    /// Returns: Returns true if successful, false otherwise.
848    ///
849    /// # Safety
850    ///
851    /// `value` should be of the correct type.
852    #[doc(alias = "CGImageMetadataSetValueWithPath")]
853    #[inline]
854    pub unsafe fn set_value_with_path(
855        &self,
856        parent: Option<&CGImageMetadataTag>,
857        path: &CFString,
858        value: &CFType,
859    ) -> bool {
860        extern "C-unwind" {
861            fn CGImageMetadataSetValueWithPath(
862                metadata: &CGMutableImageMetadata,
863                parent: Option<&CGImageMetadataTag>,
864                path: &CFString,
865                value: &CFType,
866            ) -> bool;
867        }
868        unsafe { CGImageMetadataSetValueWithPath(self, parent, path, value) }
869    }
870
871    /// Removes the tag at a specific path from a CGMutableImageMetadata container or from the parent tag
872    ///
873    /// Use this function to delete a metadata tag matching a specific
874    /// path from a mutable metadata container. Note that if a parent tag is provided,
875    /// the children of that tag reference will be modified, which may be a different
876    /// reference from the tag stored in the metadata container. Since tags are normally
877    /// obtained as a copy, it is typically neccesary to use CGImageMetadataSetTagWithPath
878    /// to commit the changed parent object back to the metadata container (using
879    /// the parent's path and NULL for the parent).
880    ///
881    /// Parameter `parent`: A parent tag. If NULL, the path is relative to the root of the
882    /// CGImageMetadataRef (i.e. it is not a child of another property).
883    ///
884    /// Parameter `path`: A string with the path to the desired tag. Please consult
885    /// the documentation of
886    ///
887    /// ```text
888    ///  CGImageMetadataCopyTagWithPath
889    /// ```
890    ///
891    /// for
892    /// information about path syntax.
893    #[doc(alias = "CGImageMetadataRemoveTagWithPath")]
894    #[inline]
895    pub unsafe fn remove_tag_with_path(
896        &self,
897        parent: Option<&CGImageMetadataTag>,
898        path: &CFString,
899    ) -> bool {
900        extern "C-unwind" {
901            fn CGImageMetadataRemoveTagWithPath(
902                metadata: &CGMutableImageMetadata,
903                parent: Option<&CGImageMetadataTag>,
904                path: &CFString,
905            ) -> bool;
906        }
907        unsafe { CGImageMetadataRemoveTagWithPath(self, parent, path) }
908    }
909}
910
911/// The block type used by CGImageMetadataEnumerateTagsUsingBlock
912///
913/// Parameter `path`: The full path to the tag in the metadata container.
914///
915/// Parameter `tag`: The CGImageMetadataTagRef corresponding to the path in metadata.
916///
917/// Returns: Return true to continue iterating through the tags, or return false to stop.
918///
919/// See also [Apple's documentation](https://developer.apple.com/documentation/imageio/cgimagemetadatatagblock?language=objc)
920#[cfg(feature = "block2")]
921pub type CGImageMetadataTagBlock =
922    *mut block2::DynBlock<dyn Fn(NonNull<CFString>, NonNull<CGImageMetadataTag>) -> bool>;
923
924impl CGImageMetadata {
925    /// Executes a given block using each tag in the metadata
926    ///
927    /// This function iterates over all of the tags in a
928    /// CGImageMetadataRef, executing the block for each tag. The default behavior
929    /// iterates over all top-level tags in the metadata. The path of the tag and
930    /// the tag itself is passed to the block. The metadata cannot be modified inside
931    /// the block - consider adding the tags of interest into another collection.
932    ///
933    /// Parameter `metadata`: A collection of metadata tags.
934    ///
935    /// Parameter `rootPath`: Iteration will occur for all children of the tag matching
936    /// the root path. Please refer to CGImageMetadataCopyTagWithPath for information
937    /// about path syntax. If NULL or an empty string, the block will be executed
938    /// for all top-level tags in the metadata container.
939    ///
940    /// Parameter `options`: A dictionary of options for iterating through the tags.
941    /// Currently the only supported option is kCGImageMetadataEnumerateRecursively,
942    /// which should be set to a CFBoolean.
943    ///
944    /// Parameter `block`: The block that is executed for each tag in metadata.
945    ///
946    /// # Safety
947    ///
948    /// - `options` generics must be of the correct type.
949    /// - `block` must be a valid pointer.
950    #[doc(alias = "CGImageMetadataEnumerateTagsUsingBlock")]
951    #[cfg(feature = "block2")]
952    #[inline]
953    pub unsafe fn enumerate_tags_using_block(
954        &self,
955        root_path: Option<&CFString>,
956        options: Option<&CFDictionary>,
957        block: CGImageMetadataTagBlock,
958    ) {
959        extern "C-unwind" {
960            fn CGImageMetadataEnumerateTagsUsingBlock(
961                metadata: &CGImageMetadata,
962                root_path: Option<&CFString>,
963                options: Option<&CFDictionary>,
964                block: CGImageMetadataTagBlock,
965            );
966        }
967        unsafe { CGImageMetadataEnumerateTagsUsingBlock(self, root_path, options, block) }
968    }
969}
970
971extern "C" {
972    /// [Apple's documentation](https://developer.apple.com/documentation/imageio/kcgimagemetadataenumeraterecursively?language=objc)
973    pub static kCGImageMetadataEnumerateRecursively: &'static CFString;
974}
975
976impl CGImageMetadata {
977    /// *!
978    ///
979    ///
980    ///
981    /// Searches for a specific CGImageMetadataTag matching a kCGImageProperty constant
982    ///
983    /// Provides a bridge for values from CGImageCopyPropertiesAtIndex, simplifying
984    /// access for properties defined in EXIF and IPTC standards, which have no notion of
985    /// namespaces, prefixes, or XMP property types.
986    /// Metadata Working Group guidance is factored into the mapping of CGImageProperties to
987    /// XMP compatible CGImageMetadataTags.
988    /// For example, kCGImagePropertyExifDateTimeOriginal will get the value of the
989    /// corresponding XMP tag, which is photoshop:DateCreated. Note that property values will
990    /// still be in their XMP forms, such as "YYYY-MM-DDThh:mm:ss" for DateTime, rather than
991    /// the EXIF or IPTC DateTime formats.
992    ///
993    /// Parameter `metadata`: A collection of metadata tags
994    ///
995    /// Parameter `dictionaryName`: the metadata subdictionary to which the image property belongs,
996    /// such as kCGImagePropertyExifDictionary or kCGImagePropertyIPTCDictionary. Not all
997    /// dictionaries and properties are supported at this time.
998    ///
999    /// Parameter `propertyName`: the name of the property. This must be a defined property constant
1000    /// corresponding to the 'dictionaryName'. For example, kCGImagePropertyTIFFOrientation,
1001    /// kCGImagePropertyExifDateTimeOriginal, or kCGImagePropertyIPTCKeywords. A warning
1002    /// will be logged if the CGImageProperty is unsupported by CGImageMetadata.
1003    ///
1004    /// Returns: Returns a CGImageMetadataTagRef with the appropriate namespace, prefix,
1005    /// tag name, and XMP value for the corresponding CGImageProperty. Returns NULL if the
1006    /// property could not be found.
1007    #[doc(alias = "CGImageMetadataCopyTagMatchingImageProperty")]
1008    #[inline]
1009    pub unsafe fn tag_matching_image_property(
1010        &self,
1011        dictionary_name: &CFString,
1012        property_name: &CFString,
1013    ) -> Option<CFRetained<CGImageMetadataTag>> {
1014        extern "C-unwind" {
1015            fn CGImageMetadataCopyTagMatchingImageProperty(
1016                metadata: &CGImageMetadata,
1017                dictionary_name: &CFString,
1018                property_name: &CFString,
1019            ) -> Option<NonNull<CGImageMetadataTag>>;
1020        }
1021        let ret = unsafe {
1022            CGImageMetadataCopyTagMatchingImageProperty(self, dictionary_name, property_name)
1023        };
1024        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1025    }
1026}
1027
1028impl CGMutableImageMetadata {
1029    /// Sets the value of the CGImageMetadataTag matching a kCGImageProperty constant
1030    ///
1031    /// Provides a bridge for values from CGImageCopyPropertiesAtIndex, simplifying
1032    /// changing property values defined in EXIF and IPTC standards, which have no notion of
1033    /// namespaces, prefixes, or XMP property types.
1034    /// Metadata Working Group guidance is factored into the mapping of CGImageProperties to
1035    /// XMP compatible CGImageMetadataTags.
1036    /// For example, setting kCGImagePropertyExifDateTimeOriginal will set the value of the
1037    /// corresponding XMP tag, which is photoshop:DateCreated. Note that property values should
1038    /// still be in their XMP forms, such as "YYYY-MM-DDThh:mm:ss" for DateTime, rather than
1039    /// the EXIF or IPTC DateTime formats. Although this function will allow the caller to set
1040    /// custom values for these properties, you should consult the appropriate specifications
1041    /// for details about property value formats for EXIF and IPTC tags in XMP.
1042    ///
1043    /// Parameter `metadata`: A mutable collection of metadata tags
1044    ///
1045    /// Parameter `dictionaryName`: the metadata subdictionary to which the image property belongs,
1046    /// such as kCGImagePropertyExifDictionary or kCGImagePropertyIPTCDictionary. Not all
1047    /// dictionaries and properties are supported at this time.
1048    ///
1049    /// Parameter `propertyName`: the name of the property. This must be a defined property constant
1050    /// corresponding to the 'dictionaryName'. For example, kCGImagePropertyTIFFOrientation,
1051    /// kCGImagePropertyExifDateTimeOriginal, or kCGImagePropertyIPTCKeywords. A warning
1052    /// will be logged if the CGImageProperty is unsupported by CGImageMetadata.
1053    ///
1054    /// Parameter `value`: A CFTypeRef with the value for the tag. The same value restrictions apply
1055    /// as in
1056    ///
1057    /// ```text
1058    ///  CGImageMetadataTagCreate
1059    /// ```
1060    ///
1061    /// .
1062    ///
1063    /// Returns: Returns true if successful, false otherwise.
1064    ///
1065    /// # Safety
1066    ///
1067    /// `value` should be of the correct type.
1068    #[doc(alias = "CGImageMetadataSetValueMatchingImageProperty")]
1069    #[inline]
1070    pub unsafe fn set_value_matching_image_property(
1071        &self,
1072        dictionary_name: &CFString,
1073        property_name: &CFString,
1074        value: &CFType,
1075    ) -> bool {
1076        extern "C-unwind" {
1077            fn CGImageMetadataSetValueMatchingImageProperty(
1078                metadata: &CGMutableImageMetadata,
1079                dictionary_name: &CFString,
1080                property_name: &CFString,
1081                value: &CFType,
1082            ) -> bool;
1083        }
1084        unsafe {
1085            CGImageMetadataSetValueMatchingImageProperty(
1086                self,
1087                dictionary_name,
1088                property_name,
1089                value,
1090            )
1091        }
1092    }
1093}
1094
1095impl CGImageMetadata {
1096    /// Serializes the CGImageMetadataRef to XMP data
1097    ///
1098    /// This converts all of the metadata tags to a block of XMP data. Common uses
1099    /// include creating sidecar files that contain metadata for image formats that do not
1100    /// support embedded XMP, or cannot be edited due to other format restrictions (such as
1101    /// proprietary RAW camera formats).
1102    ///
1103    /// Parameter `metadata`: A collection of metadata tags.
1104    ///
1105    /// Parameter `options`: should be NULL. Options are currently not used, but may be used in
1106    /// future release.
1107    ///
1108    /// Returns: Returns a CFData containing an XMP representation of the metadata. Returns
1109    /// NULL if an error occurred.
1110    ///
1111    /// # Safety
1112    ///
1113    /// `options` generics must be of the correct type.
1114    #[doc(alias = "CGImageMetadataCreateXMPData")]
1115    #[inline]
1116    pub unsafe fn xmp_data(&self, options: Option<&CFDictionary>) -> Option<CFRetained<CFData>> {
1117        extern "C-unwind" {
1118            fn CGImageMetadataCreateXMPData(
1119                metadata: &CGImageMetadata,
1120                options: Option<&CFDictionary>,
1121            ) -> Option<NonNull<CFData>>;
1122        }
1123        let ret = unsafe { CGImageMetadataCreateXMPData(self, options) };
1124        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1125    }
1126
1127    /// Creates a collection of CGImageMetadataTags from a block of XMP data
1128    ///
1129    /// Converts XMP data into a collection of metadata tags.
1130    /// The data must be a complete XMP tree. XMP packet  headers (
1131    /// <
1132    /// ?xpacket .. ?>) are
1133    /// supported.
1134    ///
1135    /// Parameter `data`: The XMP data.
1136    ///
1137    /// Returns: Returns a collection of CGImageMetadata tags. Returns NULL if an error occurred.
1138    #[doc(alias = "CGImageMetadataCreateFromXMPData")]
1139    #[inline]
1140    pub unsafe fn from_xmp_data(data: &CFData) -> Option<CFRetained<CGImageMetadata>> {
1141        extern "C-unwind" {
1142            fn CGImageMetadataCreateFromXMPData(data: &CFData) -> Option<NonNull<CGImageMetadata>>;
1143        }
1144        let ret = unsafe { CGImageMetadataCreateFromXMPData(data) };
1145        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1146    }
1147}
1148
1149extern "C" {
1150    /// Error domain for all errors originating in ImageIO for CGImageMetadata APIs.
1151    /// Error codes may be interpreted using the list below.
1152    ///
1153    /// See also [Apple's documentation](https://developer.apple.com/documentation/imageio/kcferrordomaincgimagemetadata?language=objc)
1154    pub static kCFErrorDomainCGImageMetadata: &'static CFString;
1155}
1156
1157/// the list of all error codes returned under the error domain kCFErrorDomainCGImageMetadata
1158///
1159/// See also [Apple's documentation](https://developer.apple.com/documentation/imageio/cgimagemetadataerrors?language=objc)
1160// NS_ENUM
1161#[repr(transparent)]
1162#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1163pub struct CGImageMetadataErrors(pub i32);
1164impl CGImageMetadataErrors {
1165    #[doc(alias = "kCGImageMetadataErrorUnknown")]
1166    pub const Unknown: Self = Self(0);
1167    #[doc(alias = "kCGImageMetadataErrorUnsupportedFormat")]
1168    pub const UnsupportedFormat: Self = Self(1);
1169    #[doc(alias = "kCGImageMetadataErrorBadArgument")]
1170    pub const BadArgument: Self = Self(2);
1171    #[doc(alias = "kCGImageMetadataErrorConflictingArguments")]
1172    pub const ConflictingArguments: Self = Self(3);
1173    #[doc(alias = "kCGImageMetadataErrorPrefixConflict")]
1174    pub const PrefixConflict: Self = Self(4);
1175}
1176
1177#[cfg(feature = "objc2")]
1178unsafe impl Encode for CGImageMetadataErrors {
1179    const ENCODING: Encoding = i32::ENCODING;
1180}
1181
1182#[cfg(feature = "objc2")]
1183unsafe impl RefEncode for CGImageMetadataErrors {
1184    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1185}
1186
1187#[deprecated = "renamed to `CGMutableImageMetadata::new`"]
1188#[inline]
1189pub unsafe extern "C-unwind" fn CGImageMetadataCreateMutable() -> CFRetained<CGMutableImageMetadata>
1190{
1191    extern "C-unwind" {
1192        fn CGImageMetadataCreateMutable() -> Option<NonNull<CGMutableImageMetadata>>;
1193    }
1194    let ret = unsafe { CGImageMetadataCreateMutable() };
1195    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
1196    unsafe { CFRetained::from_raw(ret) }
1197}
1198
1199#[deprecated = "renamed to `CGMutableImageMetadata::new_copy`"]
1200#[inline]
1201pub unsafe extern "C-unwind" fn CGImageMetadataCreateMutableCopy(
1202    metadata: &CGImageMetadata,
1203) -> Option<CFRetained<CGMutableImageMetadata>> {
1204    extern "C-unwind" {
1205        fn CGImageMetadataCreateMutableCopy(
1206            metadata: &CGImageMetadata,
1207        ) -> Option<NonNull<CGMutableImageMetadata>>;
1208    }
1209    let ret = unsafe { CGImageMetadataCreateMutableCopy(metadata) };
1210    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1211}
1212
1213#[deprecated = "renamed to `CGImageMetadataTag::new`"]
1214#[inline]
1215pub unsafe extern "C-unwind" fn CGImageMetadataTagCreate(
1216    xmlns: &CFString,
1217    prefix: Option<&CFString>,
1218    name: &CFString,
1219    r#type: CGImageMetadataType,
1220    value: &CFType,
1221) -> Option<CFRetained<CGImageMetadataTag>> {
1222    extern "C-unwind" {
1223        fn CGImageMetadataTagCreate(
1224            xmlns: &CFString,
1225            prefix: Option<&CFString>,
1226            name: &CFString,
1227            r#type: CGImageMetadataType,
1228            value: &CFType,
1229        ) -> Option<NonNull<CGImageMetadataTag>>;
1230    }
1231    let ret = unsafe { CGImageMetadataTagCreate(xmlns, prefix, name, r#type, value) };
1232    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1233}
1234
1235#[deprecated = "renamed to `CGImageMetadataTag::namespace`"]
1236#[inline]
1237pub unsafe extern "C-unwind" fn CGImageMetadataTagCopyNamespace(
1238    tag: &CGImageMetadataTag,
1239) -> Option<CFRetained<CFString>> {
1240    extern "C-unwind" {
1241        fn CGImageMetadataTagCopyNamespace(tag: &CGImageMetadataTag) -> Option<NonNull<CFString>>;
1242    }
1243    let ret = unsafe { CGImageMetadataTagCopyNamespace(tag) };
1244    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1245}
1246
1247#[deprecated = "renamed to `CGImageMetadataTag::prefix`"]
1248#[inline]
1249pub unsafe extern "C-unwind" fn CGImageMetadataTagCopyPrefix(
1250    tag: &CGImageMetadataTag,
1251) -> Option<CFRetained<CFString>> {
1252    extern "C-unwind" {
1253        fn CGImageMetadataTagCopyPrefix(tag: &CGImageMetadataTag) -> Option<NonNull<CFString>>;
1254    }
1255    let ret = unsafe { CGImageMetadataTagCopyPrefix(tag) };
1256    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1257}
1258
1259#[deprecated = "renamed to `CGImageMetadataTag::name`"]
1260#[inline]
1261pub unsafe extern "C-unwind" fn CGImageMetadataTagCopyName(
1262    tag: &CGImageMetadataTag,
1263) -> Option<CFRetained<CFString>> {
1264    extern "C-unwind" {
1265        fn CGImageMetadataTagCopyName(tag: &CGImageMetadataTag) -> Option<NonNull<CFString>>;
1266    }
1267    let ret = unsafe { CGImageMetadataTagCopyName(tag) };
1268    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1269}
1270
1271#[deprecated = "renamed to `CGImageMetadataTag::value`"]
1272#[inline]
1273pub unsafe extern "C-unwind" fn CGImageMetadataTagCopyValue(
1274    tag: &CGImageMetadataTag,
1275) -> Option<CFRetained<CFType>> {
1276    extern "C-unwind" {
1277        fn CGImageMetadataTagCopyValue(tag: &CGImageMetadataTag) -> Option<NonNull<CFType>>;
1278    }
1279    let ret = unsafe { CGImageMetadataTagCopyValue(tag) };
1280    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1281}
1282
1283extern "C-unwind" {
1284    #[deprecated = "renamed to `CGImageMetadataTag::type`"]
1285    pub fn CGImageMetadataTagGetType(tag: &CGImageMetadataTag) -> CGImageMetadataType;
1286}
1287
1288#[deprecated = "renamed to `CGImageMetadataTag::qualifiers`"]
1289#[inline]
1290pub unsafe extern "C-unwind" fn CGImageMetadataTagCopyQualifiers(
1291    tag: &CGImageMetadataTag,
1292) -> Option<CFRetained<CFArray>> {
1293    extern "C-unwind" {
1294        fn CGImageMetadataTagCopyQualifiers(tag: &CGImageMetadataTag) -> Option<NonNull<CFArray>>;
1295    }
1296    let ret = unsafe { CGImageMetadataTagCopyQualifiers(tag) };
1297    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1298}
1299
1300#[deprecated = "renamed to `CGImageMetadata::tags`"]
1301#[inline]
1302pub unsafe extern "C-unwind" fn CGImageMetadataCopyTags(
1303    metadata: &CGImageMetadata,
1304) -> Option<CFRetained<CFArray>> {
1305    extern "C-unwind" {
1306        fn CGImageMetadataCopyTags(metadata: &CGImageMetadata) -> Option<NonNull<CFArray>>;
1307    }
1308    let ret = unsafe { CGImageMetadataCopyTags(metadata) };
1309    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1310}
1311
1312#[deprecated = "renamed to `CGImageMetadata::tag_with_path`"]
1313#[inline]
1314pub unsafe extern "C-unwind" fn CGImageMetadataCopyTagWithPath(
1315    metadata: &CGImageMetadata,
1316    parent: Option<&CGImageMetadataTag>,
1317    path: &CFString,
1318) -> Option<CFRetained<CGImageMetadataTag>> {
1319    extern "C-unwind" {
1320        fn CGImageMetadataCopyTagWithPath(
1321            metadata: &CGImageMetadata,
1322            parent: Option<&CGImageMetadataTag>,
1323            path: &CFString,
1324        ) -> Option<NonNull<CGImageMetadataTag>>;
1325    }
1326    let ret = unsafe { CGImageMetadataCopyTagWithPath(metadata, parent, path) };
1327    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1328}
1329
1330#[deprecated = "renamed to `CGImageMetadata::string_value_with_path`"]
1331#[inline]
1332pub unsafe extern "C-unwind" fn CGImageMetadataCopyStringValueWithPath(
1333    metadata: &CGImageMetadata,
1334    parent: Option<&CGImageMetadataTag>,
1335    path: &CFString,
1336) -> Option<CFRetained<CFString>> {
1337    extern "C-unwind" {
1338        fn CGImageMetadataCopyStringValueWithPath(
1339            metadata: &CGImageMetadata,
1340            parent: Option<&CGImageMetadataTag>,
1341            path: &CFString,
1342        ) -> Option<NonNull<CFString>>;
1343    }
1344    let ret = unsafe { CGImageMetadataCopyStringValueWithPath(metadata, parent, path) };
1345    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1346}
1347
1348extern "C-unwind" {
1349    #[deprecated = "renamed to `CGMutableImageMetadata::register_namespace_for_prefix`"]
1350    pub fn CGImageMetadataRegisterNamespaceForPrefix(
1351        metadata: &CGMutableImageMetadata,
1352        xmlns: &CFString,
1353        prefix: &CFString,
1354        err: *mut *mut CFError,
1355    ) -> bool;
1356}
1357
1358extern "C-unwind" {
1359    #[deprecated = "renamed to `CGMutableImageMetadata::set_tag_with_path`"]
1360    pub fn CGImageMetadataSetTagWithPath(
1361        metadata: &CGMutableImageMetadata,
1362        parent: Option<&CGImageMetadataTag>,
1363        path: &CFString,
1364        tag: &CGImageMetadataTag,
1365    ) -> bool;
1366}
1367
1368extern "C-unwind" {
1369    #[deprecated = "renamed to `CGMutableImageMetadata::set_value_with_path`"]
1370    pub fn CGImageMetadataSetValueWithPath(
1371        metadata: &CGMutableImageMetadata,
1372        parent: Option<&CGImageMetadataTag>,
1373        path: &CFString,
1374        value: &CFType,
1375    ) -> bool;
1376}
1377
1378extern "C-unwind" {
1379    #[deprecated = "renamed to `CGMutableImageMetadata::remove_tag_with_path`"]
1380    pub fn CGImageMetadataRemoveTagWithPath(
1381        metadata: &CGMutableImageMetadata,
1382        parent: Option<&CGImageMetadataTag>,
1383        path: &CFString,
1384    ) -> bool;
1385}
1386
1387extern "C-unwind" {
1388    #[cfg(feature = "block2")]
1389    #[deprecated = "renamed to `CGImageMetadata::enumerate_tags_using_block`"]
1390    pub fn CGImageMetadataEnumerateTagsUsingBlock(
1391        metadata: &CGImageMetadata,
1392        root_path: Option<&CFString>,
1393        options: Option<&CFDictionary>,
1394        block: CGImageMetadataTagBlock,
1395    );
1396}
1397
1398#[deprecated = "renamed to `CGImageMetadata::tag_matching_image_property`"]
1399#[inline]
1400pub unsafe extern "C-unwind" fn CGImageMetadataCopyTagMatchingImageProperty(
1401    metadata: &CGImageMetadata,
1402    dictionary_name: &CFString,
1403    property_name: &CFString,
1404) -> Option<CFRetained<CGImageMetadataTag>> {
1405    extern "C-unwind" {
1406        fn CGImageMetadataCopyTagMatchingImageProperty(
1407            metadata: &CGImageMetadata,
1408            dictionary_name: &CFString,
1409            property_name: &CFString,
1410        ) -> Option<NonNull<CGImageMetadataTag>>;
1411    }
1412    let ret = unsafe {
1413        CGImageMetadataCopyTagMatchingImageProperty(metadata, dictionary_name, property_name)
1414    };
1415    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1416}
1417
1418extern "C-unwind" {
1419    #[deprecated = "renamed to `CGMutableImageMetadata::set_value_matching_image_property`"]
1420    pub fn CGImageMetadataSetValueMatchingImageProperty(
1421        metadata: &CGMutableImageMetadata,
1422        dictionary_name: &CFString,
1423        property_name: &CFString,
1424        value: &CFType,
1425    ) -> bool;
1426}
1427
1428#[deprecated = "renamed to `CGImageMetadata::xmp_data`"]
1429#[inline]
1430pub unsafe extern "C-unwind" fn CGImageMetadataCreateXMPData(
1431    metadata: &CGImageMetadata,
1432    options: Option<&CFDictionary>,
1433) -> Option<CFRetained<CFData>> {
1434    extern "C-unwind" {
1435        fn CGImageMetadataCreateXMPData(
1436            metadata: &CGImageMetadata,
1437            options: Option<&CFDictionary>,
1438        ) -> Option<NonNull<CFData>>;
1439    }
1440    let ret = unsafe { CGImageMetadataCreateXMPData(metadata, options) };
1441    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1442}
1443
1444#[deprecated = "renamed to `CGImageMetadata::from_xmp_data`"]
1445#[inline]
1446pub unsafe extern "C-unwind" fn CGImageMetadataCreateFromXMPData(
1447    data: &CFData,
1448) -> Option<CFRetained<CGImageMetadata>> {
1449    extern "C-unwind" {
1450        fn CGImageMetadataCreateFromXMPData(data: &CFData) -> Option<NonNull<CGImageMetadata>>;
1451    }
1452    let ret = unsafe { CGImageMetadataCreateFromXMPData(data) };
1453    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
1454}