objc2-media-accessibility 0.3.2

Bindings to the MediaAccessibility framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
use objc2_core_foundation::*;

use crate::*;

/// Returns an accessibility caption from an image's metadata.
///
/// Parameter `url`: The URL locating the image on disk.
///
/// Parameter `error`: If an error occurs, a description will be provided.
///
/// Returns: A string with the image caption. Nil if there's no caption.
///
/// A convenience function for retrieving a caption from an image file that aims to describe the photo accurately.
/// This checks for XMP metadata field: Iptc4xmpExt:AOContentDescription.
///
/// # Safety
///
/// `error` must be a valid pointer or null.
#[inline]
pub unsafe extern "C-unwind" fn MAImageCaptioningCopyCaption(
    url: &CFURL,
    error: *mut *mut CFError,
) -> Option<CFRetained<CFString>> {
    extern "C-unwind" {
        fn MAImageCaptioningCopyCaption(
            url: &CFURL,
            error: *mut *mut CFError,
        ) -> Option<NonNull<CFString>>;
    }
    let ret = unsafe { MAImageCaptioningCopyCaption(url, error) };
    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
}

extern "C-unwind" {
    /// Sets the accessibility caption into an image's metadata.
    ///
    /// Parameter `url`: The URL locating the image on disk.
    ///
    /// Parameter `error`: If an error occurs, a description will be provided.
    ///
    /// Parameter `string`: The accessility caption.
    ///
    /// Returns: A bool representing whether the operation was successful.
    ///
    /// A convenience function for setting a caption to an image file that aims to describe the photo accurately.
    /// This sets the XMP metadata field: Iptc4xmpExt:AOContentDescription.
    ///
    /// # Safety
    ///
    /// `error` must be a valid pointer or null.
    pub fn MAImageCaptioningSetCaption(
        url: &CFURL,
        string: Option<&CFString>,
        error: *mut *mut CFError,
    ) -> bool;
}

/// Returns the metadata tagpath for this key.
/// This tag path can be used to copy metadata directly using CGImageMetadataCopyTagWithPath from the CGImageMetadataRef, for example.
///
/// Returns: A string representing the tag path.
///
/// This returns the appropriate metadata tag path to be used.
#[inline]
pub unsafe extern "C-unwind" fn MAImageCaptioningCopyMetadataTagPath() -> CFRetained<CFString> {
    extern "C-unwind" {
        fn MAImageCaptioningCopyMetadataTagPath() -> Option<NonNull<CFString>>;
    }
    let ret = unsafe { MAImageCaptioningCopyMetadataTagPath() };
    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
    unsafe { CFRetained::from_raw(ret) }
}