pub struct CFData { /* private fields */ }
CFData
only.Expand description
This is toll-free bridged with NSData
.
Implementations§
Source§impl CFData
impl CFData
Sourcepub fn from_bytes(bytes: &[u8]) -> CFRetained<Self> ⓘ
pub fn from_bytes(bytes: &[u8]) -> CFRetained<Self> ⓘ
Creates a new CFData
from a byte slice.
Sourcepub fn from_buffer(bytes: &[u8]) -> CFRetained<Self> ⓘ
👎Deprecated: renamed to CFData::from_bytes
pub fn from_buffer(bytes: &[u8]) -> CFRetained<Self> ⓘ
Alias for easier transition from the core-foundation
crate.
Sourcepub fn from_static_bytes(bytes: &'static [u8]) -> CFRetained<Self> ⓘ
pub fn from_static_bytes(bytes: &'static [u8]) -> CFRetained<Self> ⓘ
Creates a new CFData
from a 'static
byte slice.
This may be slightly more efficient than CFData::from_bytes
, as it
may be able to re-use the existing buffer (since we know it won’t be
deallocated).
Sourcepub unsafe fn as_bytes_unchecked(&self) -> &[u8] ⓘ
pub unsafe fn as_bytes_unchecked(&self) -> &[u8] ⓘ
Source§impl CFData
impl CFData
Sourcepub unsafe fn new(
allocator: Option<&CFAllocator>,
bytes: *const u8,
length: CFIndex,
) -> Option<CFRetained<CFData>>
pub unsafe fn new( allocator: Option<&CFAllocator>, bytes: *const u8, length: CFIndex, ) -> Option<CFRetained<CFData>>
§Safety
allocator
might not allowNone
.bytes
must be a valid pointer.
Sourcepub unsafe fn with_bytes_no_copy(
allocator: Option<&CFAllocator>,
bytes: *const u8,
length: CFIndex,
bytes_deallocator: Option<&CFAllocator>,
) -> Option<CFRetained<CFData>>
pub unsafe fn with_bytes_no_copy( allocator: Option<&CFAllocator>, bytes: *const u8, length: CFIndex, bytes_deallocator: Option<&CFAllocator>, ) -> Option<CFRetained<CFData>>
§Safety
allocator
might not allowNone
.bytes
must be a valid pointer.bytes_deallocator
might not allowNone
.
pub fn new_copy( allocator: Option<&CFAllocator>, the_data: Option<&CFData>, ) -> Option<CFRetained<CFData>>
Methods from Deref<Target = CFType>§
Sourcepub fn downcast_ref<T: ConcreteType>(&self) -> Option<&T>
pub fn downcast_ref<T: ConcreteType>(&self) -> Option<&T>
Attempt to downcast the type to that of type T
.
This is the reference-variant. Use CFRetained::downcast
if you
want to convert a retained type. See also ConcreteType
for more
details on which types support being converted to.
Sourcepub fn retain_count(&self) -> usize
pub fn retain_count(&self) -> usize
Get the reference count of the object.
This function may be useful for debugging. You normally do not use this function otherwise.
Beware that some things (like CFNumber
s, small CFString
s etc.) may
not have a normal retain count for optimization purposes, and can
return usize::MAX
in that case.
Trait Implementations§
Source§impl AsRef<CFData> for CFMutableData
impl AsRef<CFData> for CFMutableData
Source§impl Borrow<CFData> for CFMutableData
impl Borrow<CFData> for CFMutableData
Source§impl ConcreteType for CFData
impl ConcreteType for CFData
Source§impl RefEncode for CFData
impl RefEncode for CFData
Source§const ENCODING_REF: Encoding
const ENCODING_REF: Encoding
Source§impl Type for CFData
impl Type for CFData
Source§fn retain(&self) -> CFRetained<Self> ⓘwhere
Self: Sized,
fn retain(&self) -> CFRetained<Self> ⓘwhere
Self: Sized,
Source§fn as_concrete_TypeRef(&self) -> &Self
fn as_concrete_TypeRef(&self) -> &Self
core-foundation
crate.Source§unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self> ⓘwhere
Self: Sized,
unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self> ⓘwhere
Self: Sized,
core-foundation
crate. Read moreSource§fn as_CFTypeRef(&self) -> &CFType
fn as_CFTypeRef(&self) -> &CFType
core-foundation
crate.Source§unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self> ⓘwhere
Self: Sized,
unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self> ⓘwhere
Self: Sized,
core-foundation
crate. Read more