pub fn from_buffer<T: AsRef<[u8]> + Sync + Send>(buffer: Arc<T>) -> Self {
        unsafe {
            let ptr = (*buffer).as_ref().as_ptr() as *const c_void;
            let len = (*buffer).as_ref().len() as size_t;
            let info = Arc::into_raw(buffer) as *mut c_void;
            let result = CGDataProviderCreateWithData(info, ptr, len, Some(release::<T>));
            return CGDataProvider::from_ptr(result);
        }

        unsafe extern "C" fn release<T>(info: *mut c_void, _: *const c_void, _: size_t) {
            drop(Arc::from_raw(info as *mut T))
        }
    }
/// Creates a data provider from the given reference-counted buffer.
///
/// The `CGDataProvider` object takes ownership of the reference. Once the data provider
/// is destroyed, the reference count of the buffer is automatically decremented.
Creates a data provider from the given reference-counted buffer.
The `CGDataProvider` object takes ownership of the reference. Once the data provider
is destroyed, the reference count of the buffer is automatically decremented.
Creates a data provider from the given reference - counted buffer . The ` CGDataProvider ` object takes ownership of the reference . Once the data provider is destroyed the reference count of the buffer is automatically decremented .
pub fn from_buffer<T: AsRef<[u8]> + Sync + Send>(buffer: Arc<T>) -> Self {
        unsafe {
            let ptr = (*buffer).as_ref().as_ptr() as *const c_void;
            let len = (*buffer).as_ref().len() as size_t;
            let info = Arc::into_raw(buffer) as *mut c_void;
            let result = CGDataProviderCreateWithData(info, ptr, len, Some(release::<T>));
            return CGDataProvider::from_ptr(result);
        }
        unsafe extern "C" fn release<T>(info: *mut c_void, _: *const c_void, _: size_t) {
            drop(Arc::from_raw(info as *mut T))
        }
    }
pub fn from_buffer < T : AsRef < [ u8 ] > + Sync + Send > ( buffer : Arc < T > ) -> Self { unsafe { let ptr = ( * buffer ) . as_ref ( ) . as_ptr ( ) as * const c_void ; let len = ( * buffer ) . as_ref ( ) . len ( ) as size_t ; let info = Arc :: into_raw ( buffer ) as * mut c_void ; let result = CGDataProviderCreateWithData ( info , ptr , len , Some ( release :: < T > ) ) ; return CGDataProvider :: from_ptr ( result ) ; } unsafe extern " " fn release < T > ( info : * mut c_void , _ : * const c_void , _ : size_t ) { drop ( Arc :: from_raw ( info as * mut T ) ) } }
Creates a data provider from the given reference-counted buffer.
Creates a data provider from the given reference - counted buffer .
buffer
Arc<T>