//! This file has been automatically generated by `objc2`'s `header-translator`. //! DO NOT EDIT use core::cell::UnsafeCell; use core::ffi::*; use core::marker::{PhantomData, PhantomPinned}; use core::ptr::NonNull; #[cfg(feature = "objc2")] use objc2::__framework_prelude::*; use objc2_core_foundation::*; use crate::*; /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgdataprovider?language=objc) #[doc(alias = "CGDataProviderRef")] #[repr(C)] pub struct CGDataProvider { inner: [u8; 0], _p: UnsafeCell, PhantomPinned)>>, } cf_type!( unsafe impl CGDataProvider {} ); #[cfg(feature = "objc2")] cf_objc2_type!( unsafe impl RefEncode<"CGDataProvider"> for CGDataProvider {} ); /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgdataprovidergetbytescallback?language=objc) pub type CGDataProviderGetBytesCallback = Option, usize) -> usize>; /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgdataproviderskipforwardcallback?language=objc) #[cfg(feature = "libc")] pub type CGDataProviderSkipForwardCallback = Option libc::off_t>; /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgdataproviderrewindcallback?language=objc) pub type CGDataProviderRewindCallback = Option; /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgdataproviderreleaseinfocallback?language=objc) pub type CGDataProviderReleaseInfoCallback = Option; /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgdataprovidersequentialcallbacks?language=objc) #[cfg(feature = "libc")] #[repr(C)] #[allow(unpredictable_function_pointer_comparisons)] #[derive(Clone, Copy, Debug, PartialEq)] pub struct CGDataProviderSequentialCallbacks { pub version: c_uint, pub getBytes: CGDataProviderGetBytesCallback, pub skipForward: CGDataProviderSkipForwardCallback, pub rewind: CGDataProviderRewindCallback, pub releaseInfo: CGDataProviderReleaseInfoCallback, } #[cfg(all(feature = "libc", feature = "objc2"))] unsafe impl Encode for CGDataProviderSequentialCallbacks { const ENCODING: Encoding = Encoding::Struct( "CGDataProviderSequentialCallbacks", &[ ::ENCODING, ::ENCODING, ::ENCODING, ::ENCODING, ::ENCODING, ], ); } #[cfg(all(feature = "libc", feature = "objc2"))] unsafe impl RefEncode for CGDataProviderSequentialCallbacks { const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING); } /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgdataprovidergetbytepointercallback?language=objc) pub type CGDataProviderGetBytePointerCallback = Option *const c_void>; /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgdataproviderreleasebytepointercallback?language=objc) pub type CGDataProviderReleaseBytePointerCallback = Option)>; /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgdataprovidergetbytesatpositioncallback?language=objc) #[cfg(feature = "libc")] pub type CGDataProviderGetBytesAtPositionCallback = Option, libc::off_t, usize) -> usize>; /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgdataproviderdirectcallbacks?language=objc) #[cfg(feature = "libc")] #[repr(C)] #[allow(unpredictable_function_pointer_comparisons)] #[derive(Clone, Copy, Debug, PartialEq)] pub struct CGDataProviderDirectCallbacks { pub version: c_uint, pub getBytePointer: CGDataProviderGetBytePointerCallback, pub releaseBytePointer: CGDataProviderReleaseBytePointerCallback, pub getBytesAtPosition: CGDataProviderGetBytesAtPositionCallback, pub releaseInfo: CGDataProviderReleaseInfoCallback, } #[cfg(all(feature = "libc", feature = "objc2"))] unsafe impl Encode for CGDataProviderDirectCallbacks { const ENCODING: Encoding = Encoding::Struct( "CGDataProviderDirectCallbacks", &[ ::ENCODING, ::ENCODING, ::ENCODING, ::ENCODING, ::ENCODING, ], ); } #[cfg(all(feature = "libc", feature = "objc2"))] unsafe impl RefEncode for CGDataProviderDirectCallbacks { const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING); } unsafe impl ConcreteType for CGDataProvider { #[doc(alias = "CGDataProviderGetTypeID")] #[inline] fn type_id() -> CFTypeID { extern "C-unwind" { fn CGDataProviderGetTypeID() -> CFTypeID; } unsafe { CGDataProviderGetTypeID() } } } impl CGDataProvider { /// # Safety /// /// - `info` must be a valid pointer or null. /// - `callbacks` must be a valid pointer or null. #[doc(alias = "CGDataProviderCreateSequential")] #[cfg(feature = "libc")] #[inline] pub unsafe fn new_sequential( info: *mut c_void, callbacks: *const CGDataProviderSequentialCallbacks, ) -> Option> { extern "C-unwind" { fn CGDataProviderCreateSequential( info: *mut c_void, callbacks: *const CGDataProviderSequentialCallbacks, ) -> Option>; } let ret = unsafe { CGDataProviderCreateSequential(info, callbacks) }; ret.map(|ret| unsafe { CFRetained::from_raw(ret) }) } /// # Safety /// /// - `info` must be a valid pointer or null. /// - `callbacks` must be a valid pointer or null. #[doc(alias = "CGDataProviderCreateDirect")] #[cfg(feature = "libc")] #[inline] pub unsafe fn new_direct( info: *mut c_void, size: libc::off_t, callbacks: *const CGDataProviderDirectCallbacks, ) -> Option> { extern "C-unwind" { fn CGDataProviderCreateDirect( info: *mut c_void, size: libc::off_t, callbacks: *const CGDataProviderDirectCallbacks, ) -> Option>; } let ret = unsafe { CGDataProviderCreateDirect(info, size, callbacks) }; ret.map(|ret| unsafe { CFRetained::from_raw(ret) }) } } /// [Apple's documentation](https://developer.apple.com/documentation/coregraphics/cgdataproviderreleasedatacallback?language=objc) pub type CGDataProviderReleaseDataCallback = Option, usize)>; impl CGDataProvider { /// # Safety /// /// - `info` must be a valid pointer or null. /// - `data` must be a valid pointer or null. /// - `release_data` must be implemented correctly. #[doc(alias = "CGDataProviderCreateWithData")] #[inline] pub unsafe fn with_data( info: *mut c_void, data: *const c_void, size: usize, release_data: CGDataProviderReleaseDataCallback, ) -> Option> { extern "C-unwind" { fn CGDataProviderCreateWithData( info: *mut c_void, data: *const c_void, size: usize, release_data: CGDataProviderReleaseDataCallback, ) -> Option>; } let ret = unsafe { CGDataProviderCreateWithData(info, data, size, release_data) }; ret.map(|ret| unsafe { CFRetained::from_raw(ret) }) } #[doc(alias = "CGDataProviderCreateWithCFData")] #[inline] pub fn with_cf_data(data: Option<&CFData>) -> Option> { extern "C-unwind" { fn CGDataProviderCreateWithCFData( data: Option<&CFData>, ) -> Option>; } let ret = unsafe { CGDataProviderCreateWithCFData(data) }; ret.map(|ret| unsafe { CFRetained::from_raw(ret) }) } #[doc(alias = "CGDataProviderCreateWithURL")] #[inline] pub fn with_url(url: Option<&CFURL>) -> Option> { extern "C-unwind" { fn CGDataProviderCreateWithURL(url: Option<&CFURL>) -> Option>; } let ret = unsafe { CGDataProviderCreateWithURL(url) }; ret.map(|ret| unsafe { CFRetained::from_raw(ret) }) } /// # Safety /// /// `filename` must be a valid pointer or null. #[doc(alias = "CGDataProviderCreateWithFilename")] #[inline] pub unsafe fn with_filename(filename: *const c_char) -> Option> { extern "C-unwind" { fn CGDataProviderCreateWithFilename( filename: *const c_char, ) -> Option>; } let ret = unsafe { CGDataProviderCreateWithFilename(filename) }; ret.map(|ret| unsafe { CFRetained::from_raw(ret) }) } #[doc(alias = "CGDataProviderCopyData")] #[inline] pub fn data(provider: Option<&CGDataProvider>) -> Option> { extern "C-unwind" { fn CGDataProviderCopyData(provider: Option<&CGDataProvider>) -> Option>; } let ret = unsafe { CGDataProviderCopyData(provider) }; ret.map(|ret| unsafe { CFRetained::from_raw(ret) }) } #[doc(alias = "CGDataProviderGetInfo")] #[inline] pub fn info(provider: Option<&CGDataProvider>) -> *mut c_void { extern "C-unwind" { fn CGDataProviderGetInfo(provider: Option<&CGDataProvider>) -> *mut c_void; } unsafe { CGDataProviderGetInfo(provider) } } } #[cfg(feature = "libc")] #[deprecated = "renamed to `CGDataProvider::new_sequential`"] #[inline] pub unsafe extern "C-unwind" fn CGDataProviderCreateSequential( info: *mut c_void, callbacks: *const CGDataProviderSequentialCallbacks, ) -> Option> { extern "C-unwind" { fn CGDataProviderCreateSequential( info: *mut c_void, callbacks: *const CGDataProviderSequentialCallbacks, ) -> Option>; } let ret = unsafe { CGDataProviderCreateSequential(info, callbacks) }; ret.map(|ret| unsafe { CFRetained::from_raw(ret) }) } #[cfg(feature = "libc")] #[deprecated = "renamed to `CGDataProvider::new_direct`"] #[inline] pub unsafe extern "C-unwind" fn CGDataProviderCreateDirect( info: *mut c_void, size: libc::off_t, callbacks: *const CGDataProviderDirectCallbacks, ) -> Option> { extern "C-unwind" { fn CGDataProviderCreateDirect( info: *mut c_void, size: libc::off_t, callbacks: *const CGDataProviderDirectCallbacks, ) -> Option>; } let ret = unsafe { CGDataProviderCreateDirect(info, size, callbacks) }; ret.map(|ret| unsafe { CFRetained::from_raw(ret) }) } #[deprecated = "renamed to `CGDataProvider::with_data`"] #[inline] pub unsafe extern "C-unwind" fn CGDataProviderCreateWithData( info: *mut c_void, data: *const c_void, size: usize, release_data: CGDataProviderReleaseDataCallback, ) -> Option> { extern "C-unwind" { fn CGDataProviderCreateWithData( info: *mut c_void, data: *const c_void, size: usize, release_data: CGDataProviderReleaseDataCallback, ) -> Option>; } let ret = unsafe { CGDataProviderCreateWithData(info, data, size, release_data) }; ret.map(|ret| unsafe { CFRetained::from_raw(ret) }) } #[deprecated = "renamed to `CGDataProvider::with_cf_data`"] #[inline] pub extern "C-unwind" fn CGDataProviderCreateWithCFData( data: Option<&CFData>, ) -> Option> { extern "C-unwind" { fn CGDataProviderCreateWithCFData(data: Option<&CFData>) -> Option>; } let ret = unsafe { CGDataProviderCreateWithCFData(data) }; ret.map(|ret| unsafe { CFRetained::from_raw(ret) }) } #[deprecated = "renamed to `CGDataProvider::with_url`"] #[inline] pub extern "C-unwind" fn CGDataProviderCreateWithURL( url: Option<&CFURL>, ) -> Option> { extern "C-unwind" { fn CGDataProviderCreateWithURL(url: Option<&CFURL>) -> Option>; } let ret = unsafe { CGDataProviderCreateWithURL(url) }; ret.map(|ret| unsafe { CFRetained::from_raw(ret) }) } #[deprecated = "renamed to `CGDataProvider::with_filename`"] #[inline] pub unsafe extern "C-unwind" fn CGDataProviderCreateWithFilename( filename: *const c_char, ) -> Option> { extern "C-unwind" { fn CGDataProviderCreateWithFilename( filename: *const c_char, ) -> Option>; } let ret = unsafe { CGDataProviderCreateWithFilename(filename) }; ret.map(|ret| unsafe { CFRetained::from_raw(ret) }) } #[deprecated = "renamed to `CGDataProvider::data`"] #[inline] pub extern "C-unwind" fn CGDataProviderCopyData( provider: Option<&CGDataProvider>, ) -> Option> { extern "C-unwind" { fn CGDataProviderCopyData(provider: Option<&CGDataProvider>) -> Option>; } let ret = unsafe { CGDataProviderCopyData(provider) }; ret.map(|ret| unsafe { CFRetained::from_raw(ret) }) } #[deprecated = "renamed to `CGDataProvider::info`"] #[inline] pub extern "C-unwind" fn CGDataProviderGetInfo(provider: Option<&CGDataProvider>) -> *mut c_void { extern "C-unwind" { fn CGDataProviderGetInfo(provider: Option<&CGDataProvider>) -> *mut c_void; } unsafe { CGDataProviderGetInfo(provider) } }