Struct NSData

Source
#[repr(C)]
pub struct NSData { pub ptr: Id<Object>, }
Expand description

A static byte buffer in memory.

Fields§

§ptr: Id<Object>

The raw pointer to the Objective-C object.

Implementations§

Source§

impl NSData

Source

pub fn data() -> Self

Creates an empty data object.

Source

pub fn data_with_bytes_length(bytes: *const c_void, length: UInt) -> Self

Creates a data object containing a given number of bytes copied from a given buffer.

Source

pub fn data_with_bytes_no_copy_length(bytes: *mut c_void, length: UInt) -> Self

Creates a data object that holds a given number of bytes from a given buffer.

Source

pub fn data_with_bytes_no_copy_length_free_when_done( bytes: *mut c_void, length: UInt, b: bool, ) -> Self

Creates a data object that holds a given number of bytes from a given buffer.

Source

pub fn data_with_data(data: NSData) -> Self

Creates a data object containing the contents of another data object.

Source

pub fn init_with_bytes_length( &mut self, bytes: *const c_void, length: UInt, ) -> Self
where Self: Sized + FromId,

Initializes a data object filled with a given number of bytes copied from a given buffer.

Source

pub fn init_with_bytes_no_copy_length( &mut self, bytes: *mut c_void, length: UInt, ) -> Self
where Self: Sized + FromId,

Initializes a data object filled with a given number of bytes of data from a given buffer.

Source

pub fn init_with_bytes_no_copy_length_deallocator<F>( &mut self, bytes: *mut c_void, length: UInt, deallocator: F, ) -> Self
where Self: Sized + FromId, F: IntoConcreteBlock<(*mut c_void, UInt), Ret = ()> + 'static,

Initializes a data object filled with a given number of bytes of data from a given buffer, with a custom deallocator block.

Source

pub fn init_with_bytes_no_copy_length_free_when_done( &mut self, bytes: *mut c_void, length: UInt, b: bool, ) -> Self
where Self: Sized + FromId,

Initializes a newly allocated data object by adding the given number of bytes from the given buffer.

Source

pub fn init_with_data(&mut self, data: &NSData) -> Self
where Self: Sized + FromId,

Initializes a data object with the contents of another data object.

Source

pub fn data_with_contents_of_file(path: &NSString) -> Self

Creates a data object by reading every byte from the file at a given path.

Source

pub fn data_with_contents_of_file_options( path: &NSString, read_options_mask: NSDataReadingOptions, ) -> Result<Self, NSError>

Creates a data object by reading every byte from the file at a given path.

Source

pub fn data_with_contents_of_url(url: &NSURL) -> Self

Creates a data object containing the data from the location specified by a given URL.

Source

pub fn data_with_contents_of_url_options( url: &NSURL, read_options_mask: NSDataReadingOptions, ) -> Result<Self, NSError>

Creates a data object containing the data from the location specified by a given URL.

Source

pub fn init_with_contents_of_file(&mut self, path: &NSString) -> Self
where Self: Sized + FromId,

Initializes a data object with the content of the file at a given path.

Source

pub fn init_with_contents_of_file_options( &mut self, path: &NSString, read_options_mask: NSDataReadingOptions, ) -> Result<Self, NSError>
where Self: Sized + FromId,

Initializes a data object with the content of the file at a given path.

Source

pub fn init_with_contents_of_url(&mut self, url: &NSURL) -> Self
where Self: Sized + FromId,

Initializes a data object with the data from the location specified by a given URL.

Source

pub fn init_with_contents_of_url_options( &mut self, url: &NSURL, read_options_mask: NSDataReadingOptions, ) -> Result<Self, NSError>
where Self: Sized + FromId,

Initializes a data object with the data from the location specified by a given URL.

Source

pub fn write_to_file_atomically( &self, path: &NSString, use_auxiliary_file: bool, ) -> bool

Writes the data object’s bytes to the file specified by a given path.

Source

pub fn write_to_file_options( &self, path: &NSString, write_options: NSDataWritingOptions, ) -> Result<bool, NSError>

Writes the data object’s bytes to the file specified by a given path.

Source

pub fn write_to_url_atomically(&self, url: &NSURL, atomically: bool) -> bool

Writes the data object’s bytes to the location specified by a given URL.

Source

pub fn write_to_url_options( &self, url: &NSURL, write_options: NSDataWritingOptions, ) -> Result<bool, NSError>

Writes the data object’s bytes to the location specified by a given URL.

Source

pub fn init_with_base64_encoded_data_options( &mut self, base64_data: &NSData, options: NSDataBase64DecodingOptions, ) -> Self
where Self: Sized + FromId,

Initializes a data object with the given Base64 encoded data.

Source

pub fn init_with_base64_encoded_string_options( &mut self, base64_string: &NSString, options: NSDataBase64DecodingOptions, ) -> Self
where Self: Sized + FromId,

Initializes a data object with the given Base64 encoded string.

Source

pub fn base64_encoded_data_with_options( &self, options: NSDataBase64EncodingOptions, ) -> NSData

Creates a Base64, UTF-8 encoded data object from the string using the given options.

Source

pub fn base64_encoded_string_with_options( &self, options: NSDataBase64EncodingOptions, ) -> NSString

Creates a Base64 encoded string from the string using the given options.

Source

pub fn bytes(&self) -> *const c_void

A pointer to the data object’s contents.

Source

pub fn enumerate_byte_ranges_using_block<F>(&self, block: F)
where F: IntoConcreteBlock<(*const c_void, NSRange, *mut bool), Ret = ()> + 'static,

Enumerates each range of bytes in the data object using a block.

Source

pub fn get_bytes_length(&self, buffer: *mut c_void, length: UInt)

Copies a number of bytes from the start of the data object into a given buffer.

Source

pub fn get_bytes_range(&self, buffer: *mut c_void, range: NSRange)

Copies a range of bytes from the data object into a given buffer.

Source

pub fn subdata_with_range(&self, range: NSRange) -> NSData

Returns a new data object containing the data object’s bytes that fall within the limits specified by a given range.

Source

pub fn range_of_data_options_range( &self, data_to_find: &NSData, mask: NSDataSearchOptions, search_range: NSRange, ) -> NSRange

Finds and returns the range of the first occurrence of the given data, within the given range, subject to given options.

Source

pub fn is_equal_to_data(&self, other: &NSData) -> bool

Returns a Boolean value indicating whether this data object is the same as another.

Source

pub fn length(&self) -> UInt

The number of bytes contained by the data object.

Source

pub fn compressed_data_using_algorithm( &self, algorithm: NSDataCompressionAlgorithm, ) -> Result<Self, NSError>
where Self: Sized + FromId,

Returns a new data object by compressing the data object’s bytes.

Source

pub fn decompressed_data_using_algorithm( &self, algorithm: NSDataCompressionAlgorithm, ) -> Result<Self, NSError>
where Self: Sized + FromId,

Returns a new data object by decompressing data object’s bytes.

Methods from Deref<Target = Object>§

Source

pub fn class(&self) -> &Class

Returns the class of self.

Source

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.

Source

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.

Source

pub unsafe fn set_ivar<T>(&mut self, name: &str, value: T)
where T: Encode,

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§

Source§

impl Clone for NSData

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NSData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for NSData

Source§

type Target = Object

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for NSData

Source§

fn deref_mut(&mut self) -> &mut Object

Mutably dereferences the value.
Source§

impl Display for NSData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Encode for NSData

Source§

fn encode() -> Encoding

Returns the Objective-C type encoding for Self.
Source§

impl FromId for NSData

Source§

unsafe fn from_id(ptr: id) -> Self

Returns Self representation of the object. Read more
Source§

impl Hash for NSData

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl INSData for NSData

Source§

fn m_data() -> Self
where Self: Sized + FromId,

Creates an empty data object.
Source§

fn m_data_with_bytes_length(bytes: *const c_void, length: UInt) -> Self
where Self: Sized + FromId,

Creates a data object containing a given number of bytes copied from a given buffer.
Source§

fn m_data_with_bytes_no_copy_length(bytes: *mut c_void, length: UInt) -> Self
where Self: Sized + FromId,

Creates a data object that holds a given number of bytes from a given buffer.
Source§

fn m_data_with_bytes_no_copy_length_free_when_done( bytes: *mut c_void, length: UInt, b: bool, ) -> Self
where Self: Sized + FromId,

Creates a data object that holds a given number of bytes from a given buffer.
Source§

fn m_data_with_data(data: NSData) -> Self
where Self: Sized + FromId,

Creates a data object containing the contents of another data object.
Source§

fn m_init_with_bytes_length( &mut self, bytes: *const c_void, length: UInt, ) -> Self
where Self: Sized + FromId,

Initializes a data object filled with a given number of bytes copied from a given buffer.
Source§

fn m_init_with_bytes_no_copy_length( &mut self, bytes: *mut c_void, length: UInt, ) -> Self
where Self: Sized + FromId,

Initializes a data object filled with a given number of bytes of data from a given buffer.
Source§

fn m_init_with_bytes_no_copy_length_deallocator<F>( &mut self, bytes: *mut c_void, length: UInt, deallocator: F, ) -> Self
where Self: Sized + FromId, F: IntoConcreteBlock<(*mut c_void, UInt), Ret = ()> + 'static,

Initializes a data object filled with a given number of bytes of data from a given buffer, with a custom deallocator block.
Source§

fn m_init_with_bytes_no_copy_length_free_when_done( &mut self, bytes: *mut c_void, length: UInt, b: bool, ) -> Self
where Self: Sized + FromId,

Initializes a newly allocated data object by adding the given number of bytes from the given buffer.
Source§

fn m_init_with_data(&mut self, data: &NSData) -> Self
where Self: Sized + FromId,

Initializes a data object with the contents of another data object.
Source§

fn m_data_with_contents_of_file(path: &NSString) -> Self
where Self: Sized + FromId,

Creates a data object by reading every byte from the file at a given path.
Source§

fn m_data_with_contents_of_file_options( path: &NSString, read_options_mask: NSDataReadingOptions, ) -> Result<Self, NSError>
where Self: Sized + FromId,

Creates a data object by reading every byte from the file at a given path.
Source§

fn m_data_with_contents_of_url(url: &NSURL) -> Self
where Self: Sized + FromId,

Creates a data object containing the data from the location specified by a given URL.
Source§

fn m_data_with_contents_of_url_options( url: &NSURL, read_options_mask: NSDataReadingOptions, ) -> Result<Self, NSError>
where Self: Sized + FromId,

Creates a data object containing the data from the location specified by a given URL.
Source§

fn m_init_with_contents_of_file(&mut self, path: &NSString) -> Self
where Self: Sized + FromId,

Initializes a data object with the content of the file at a given path.
Source§

fn m_init_with_contents_of_file_options( &mut self, path: &NSString, read_options_mask: NSDataReadingOptions, ) -> Result<Self, NSError>
where Self: Sized + FromId,

Initializes a data object with the content of the file at a given path.
Source§

fn m_init_with_contents_of_url(&mut self, url: &NSURL) -> Self
where Self: Sized + FromId,

Initializes a data object with the data from the location specified by a given URL.
Source§

fn m_init_with_contents_of_url_options( &mut self, url: &NSURL, read_options_mask: NSDataReadingOptions, ) -> Result<Self, NSError>
where Self: Sized + FromId,

Initializes a data object with the data from the location specified by a given URL.
Source§

fn m_write_to_file_atomically( &self, path: &NSString, use_auxiliary_file: bool, ) -> bool

Writes the data object’s bytes to the file specified by a given path.
Source§

fn m_write_to_file_options( &self, path: &NSString, write_options: NSDataWritingOptions, ) -> Result<bool, NSError>

Writes the data object’s bytes to the file specified by a given path.
Source§

fn m_write_to_url_atomically(&self, url: &NSURL, atomically: bool) -> bool

Writes the data object’s bytes to the location specified by a given URL.
Source§

fn m_write_to_url_options( &self, url: &NSURL, write_options: NSDataWritingOptions, ) -> Result<bool, NSError>

Writes the data object’s bytes to the location specified by a given URL.
Source§

fn m_init_with_base64_encoded_data_options( &mut self, base64_data: &NSData, options: NSDataBase64DecodingOptions, ) -> Self
where Self: Sized + FromId,

Initializes a data object with the given Base64 encoded data.
Source§

fn m_init_with_base64_encoded_string_options( &mut self, base64_string: &NSString, options: NSDataBase64DecodingOptions, ) -> Self
where Self: Sized + FromId,

Initializes a data object with the given Base64 encoded string.
Source§

fn m_base64_encoded_data_with_options( &self, options: NSDataBase64EncodingOptions, ) -> NSData

Creates a Base64, UTF-8 encoded data object from the string using the given options.
Source§

fn m_base64_encoded_string_with_options( &self, options: NSDataBase64EncodingOptions, ) -> NSString

Creates a Base64 encoded string from the string using the given options.
Source§

fn p_bytes(&self) -> *const c_void

A pointer to the data object’s contents.
Source§

fn m_enumerate_byte_ranges_using_block<F>(&self, block: F)
where F: IntoConcreteBlock<(*const c_void, NSRange, *mut bool), Ret = ()> + 'static,

Enumerates each range of bytes in the data object using a block.
Source§

fn m_get_bytes_length(&self, buffer: *mut c_void, length: UInt)

Copies a number of bytes from the start of the data object into a given buffer.
Source§

fn m_get_bytes_range(&self, buffer: *mut c_void, range: NSRange)

Copies a range of bytes from the data object into a given buffer.
Source§

fn m_subdata_with_range(&self, range: NSRange) -> NSData

Returns a new data object containing the data object’s bytes that fall within the limits specified by a given range.
Source§

fn m_range_of_data_options_range( &self, data_to_find: &NSData, mask: NSDataSearchOptions, search_range: NSRange, ) -> NSRange

Finds and returns the range of the first occurrence of the given data, within the given range, subject to given options.
Source§

fn m_is_equal_to_data(&self, other: &NSData) -> bool

Returns a Boolean value indicating whether this data object is the same as another.
Source§

fn m_length(&self) -> UInt

The number of bytes contained by the data object.
Source§

fn m_compressed_data_using_algorithm( &self, algorithm: NSDataCompressionAlgorithm, ) -> Result<Self, NSError>
where Self: Sized + FromId,

Returns a new data object by compressing the data object’s bytes.
Source§

fn m_decompressed_data_using_algorithm( &self, algorithm: NSDataCompressionAlgorithm, ) -> Result<Self, NSError>
where Self: Sized + FromId,

Returns a new data object by decompressing data object’s bytes.
Source§

impl PNSObject for NSData

Source§

fn m_class<'a>() -> &'a Class

Returns the class object for the receiver’s class.
Source§

fn m_self(&self) -> id

Returns the receiver.
Source§

fn m_new() -> Self
where Self: Sized + FromId,

Allocates a new instance of the receiving class, sends it an init message, and returns the initialized object.
Source§

fn m_alloc() -> Self
where Self: Sized + FromId,

Returns a new instance of the receiving class.
Source§

fn m_initialize()

Initializes the class before it receives its first message.
Source§

fn ip_superclass<'a>() -> Option<&'a Class>

Returns the class object for the receiver’s superclass.
Source§

fn m_is_equal(&self, object: &Self) -> bool

Returns a Boolean value that indicates whether the receiver and a given object are equal.
Source§

fn p_hash(&self) -> UInt

Returns an integer that can be used as a table address in a hash table structure.
Source§

fn m_is_kind_of_class(&self, class: Class) -> bool

Returns a Boolean value that indicates whether the receiver is an instance of given class or an instance of any class that inherits from that class.
Source§

fn m_is_member_of_class(&self, class: Class) -> bool

Returns a Boolean value that indicates whether the receiver is an instance of a given class.
Source§

fn m_responds_to_selector(&self, selector: Sel) -> bool

Returns a Boolean value that indicates whether the receiver implements or inherits a method that can respond to a specified message.
Source§

fn m_conforms_to_protocol(&self, protocol: Protocol) -> bool

Returns a Boolean value that indicates whether the receiver conforms to a given protocol.
Source§

fn p_description(&self) -> NSString

A textual representation of the receiver.
Source§

fn p_debug_description(&self) -> NSString

A textual representation of the receiver to use with a debugger.
Source§

fn m_perform_selector(&self, selector: Sel) -> id

Sends a specified message to the receiver and returns the result of the message.
Source§

fn m_perform_selector_with_object(&self, selector: Sel, with_object: id) -> id

Sends a message to the receiver with an object as the argument.
Source§

fn m_is_proxy(&self) -> bool

Returns a Boolean value that indicates whether the receiver does not descend from NSObject.
Source§

impl ToId for NSData

Source§

fn to_id(self) -> id

Returns id representation of the object.

Auto Trait Implementations§

§

impl Freeze for NSData

§

impl RefUnwindSafe for NSData

§

impl Send for NSData

§

impl Sync for NSData

§

impl Unpin for NSData

§

impl UnwindSafe for NSData

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.