objc2_core_graphics/generated/
CGPDFString.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/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgpdfstring?language=objc)
14#[repr(C)]
15#[derive(Debug)]
16pub struct CGPDFString {
17    inner: [u8; 0],
18    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
19}
20
21#[cfg(feature = "objc2")]
22unsafe impl RefEncode for CGPDFString {
23    const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("CGPDFString", &[]));
24}
25
26/// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgpdfstringref?language=objc)
27pub type CGPDFStringRef = *mut CGPDFString;
28
29impl CGPDFString {
30    /// # Safety
31    ///
32    /// `string` must be a valid pointer or null.
33    #[doc(alias = "CGPDFStringGetLength")]
34    #[inline]
35    pub unsafe fn length(string: CGPDFStringRef) -> usize {
36        extern "C-unwind" {
37            fn CGPDFStringGetLength(string: CGPDFStringRef) -> usize;
38        }
39        unsafe { CGPDFStringGetLength(string) }
40    }
41
42    /// # Safety
43    ///
44    /// `string` must be a valid pointer or null.
45    #[doc(alias = "CGPDFStringGetBytePtr")]
46    #[inline]
47    pub unsafe fn byte_ptr(string: CGPDFStringRef) -> *const c_uchar {
48        extern "C-unwind" {
49            fn CGPDFStringGetBytePtr(string: CGPDFStringRef) -> *const c_uchar;
50        }
51        unsafe { CGPDFStringGetBytePtr(string) }
52    }
53
54    /// # Safety
55    ///
56    /// `string` must be a valid pointer or null.
57    #[doc(alias = "CGPDFStringCopyTextString")]
58    #[inline]
59    pub unsafe fn text_string(string: CGPDFStringRef) -> Option<CFRetained<CFString>> {
60        extern "C-unwind" {
61            fn CGPDFStringCopyTextString(string: CGPDFStringRef) -> Option<NonNull<CFString>>;
62        }
63        let ret = unsafe { CGPDFStringCopyTextString(string) };
64        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
65    }
66
67    /// # Safety
68    ///
69    /// `string` must be a valid pointer or null.
70    #[doc(alias = "CGPDFStringCopyDate")]
71    #[inline]
72    pub unsafe fn date(string: CGPDFStringRef) -> Option<CFRetained<CFDate>> {
73        extern "C-unwind" {
74            fn CGPDFStringCopyDate(string: CGPDFStringRef) -> Option<NonNull<CFDate>>;
75        }
76        let ret = unsafe { CGPDFStringCopyDate(string) };
77        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
78    }
79}
80
81extern "C-unwind" {
82    #[deprecated = "renamed to `CGPDFString::length`"]
83    pub fn CGPDFStringGetLength(string: CGPDFStringRef) -> usize;
84}
85
86extern "C-unwind" {
87    #[deprecated = "renamed to `CGPDFString::byte_ptr`"]
88    pub fn CGPDFStringGetBytePtr(string: CGPDFStringRef) -> *const c_uchar;
89}
90
91#[deprecated = "renamed to `CGPDFString::text_string`"]
92#[inline]
93pub unsafe extern "C-unwind" fn CGPDFStringCopyTextString(
94    string: CGPDFStringRef,
95) -> Option<CFRetained<CFString>> {
96    extern "C-unwind" {
97        fn CGPDFStringCopyTextString(string: CGPDFStringRef) -> Option<NonNull<CFString>>;
98    }
99    let ret = unsafe { CGPDFStringCopyTextString(string) };
100    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
101}
102
103#[deprecated = "renamed to `CGPDFString::date`"]
104#[inline]
105pub unsafe extern "C-unwind" fn CGPDFStringCopyDate(
106    string: CGPDFStringRef,
107) -> Option<CFRetained<CFDate>> {
108    extern "C-unwind" {
109        fn CGPDFStringCopyDate(string: CGPDFStringRef) -> Option<NonNull<CFDate>>;
110    }
111    let ret = unsafe { CGPDFStringCopyDate(string) };
112    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
113}