pub struct NSData(pub Id<Object>);
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

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.

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.

Given a (presumably) NSData, wraps and retains it.

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.

A helper method for determining if a given NSObject is an NSData.

Returns the length of the underlying NSData bytes.

Returns a reference to the underlying bytes for the wrapped NSData.

This, like NSData::new(), is cribbed from objc-foundation.

objc-foundation

Creates a new Vec, copies the NSData (safely, but quickly) bytes into that Vec, and consumes the NSData enabling it to release (provided nothing in Cocoa is using it).

Methods from Deref<Target = Object>

Returns the class of self.

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.

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.

Sets the value of 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

Formats the value using the given formatter. Read more

Derefs to the underlying Objective-C Object.

The resulting type after dereferencing.

Derefs to the underlying Objective-C Object.

Consumes and returns the underlying NSData.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.