Struct cacao::foundation::NSData
source · [−]Expand description
Wrapper for a retained NSData
object.
Supports constructing a new NSData
from a Vec<u8>
, wrapping and retaining an existing
pointer from the Objective-C side, and turning an NSData
into a Vec<u8>
.
This is an intentionally limited API.
Tuple Fields
0: Id<Object>
Implementations
sourceimpl NSData
impl NSData
sourcepub fn new(bytes: Vec<u8>) -> Self
pub fn new(bytes: Vec<u8>) -> Self
Given a vector of bytes, creates, retains, and returns a wrapped NSData
.
This method is borrowed straight out of objc-foundation by the amazing Steven Sheldon, and just tweaked slightly to fit the desired API semantics here.
sourcepub fn with_slice(bytes: &[u8]) -> Self
pub fn with_slice(bytes: &[u8]) -> Self
Given a slice of bytes, creates, retains, and returns a wrapped NSData
.
This method is borrowed straight out of objc-foundation by the amazing Steven Sheldon, and just tweaked slightly to fit the desired API semantics here.
sourcepub fn from_retained(data: id) -> Self
pub fn from_retained(data: id) -> Self
If we’re vended an NSData from a method (e.g, a push notification token) we might want to wrap it while we figure out what to do with it. This does that.
Methods from Deref<Target = Object>
sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &T where
T: Encode,
pub unsafe fn get_ivar<T>(&self, name: &str) -> &T where
T: Encode,
Returns a reference to the ivar of self with the given name.
Panics if self has no ivar with the given name.
Unsafe because the caller must ensure that the ivar is actually
of type T
.
sourcepub unsafe fn get_mut_ivar<T>(&mut self, name: &str) -> &mut T where
T: Encode,
pub unsafe fn get_mut_ivar<T>(&mut self, name: &str) -> &mut T where
T: Encode,
Returns a mutable reference to the ivar of self with the given name.
Panics if self has no ivar with the given name.
Unsafe because the caller must ensure that the ivar is actually
of type T
.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for NSData
impl Send for NSData
impl Sync for NSData
impl Unpin for NSData
impl UnwindSafe for NSData
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more