#[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
impl NSData
Sourcepub fn data_with_bytes_length(bytes: *const c_void, length: UInt) -> Self
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.
Sourcepub fn data_with_bytes_no_copy_length(bytes: *mut c_void, length: UInt) -> Self
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.
Sourcepub fn data_with_bytes_no_copy_length_free_when_done(
bytes: *mut c_void,
length: UInt,
b: bool,
) -> Self
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.
Sourcepub fn data_with_data(data: NSData) -> Self
pub fn data_with_data(data: NSData) -> Self
Creates a data object containing the contents of another data object.
Sourcepub fn init_with_bytes_length(
&mut self,
bytes: *const c_void,
length: UInt,
) -> Self
pub fn init_with_bytes_length( &mut self, bytes: *const c_void, length: UInt, ) -> Self
Initializes a data object filled with a given number of bytes copied from a given buffer.
Sourcepub fn init_with_bytes_no_copy_length(
&mut self,
bytes: *mut c_void,
length: UInt,
) -> Self
pub fn init_with_bytes_no_copy_length( &mut self, bytes: *mut c_void, length: UInt, ) -> Self
Initializes a data object filled with a given number of bytes of data from a given buffer.
Sourcepub fn init_with_bytes_no_copy_length_deallocator<F>(
&mut self,
bytes: *mut c_void,
length: UInt,
deallocator: F,
) -> Self
pub fn init_with_bytes_no_copy_length_deallocator<F>( &mut self, bytes: *mut c_void, length: UInt, deallocator: F, ) -> Self
Initializes a data object filled with a given number of bytes of data from a given buffer, with a custom deallocator block.
Sourcepub fn init_with_bytes_no_copy_length_free_when_done(
&mut self,
bytes: *mut c_void,
length: UInt,
b: bool,
) -> Self
pub fn init_with_bytes_no_copy_length_free_when_done( &mut self, bytes: *mut c_void, length: UInt, b: bool, ) -> Self
Initializes a newly allocated data object by adding the given number of bytes from the given buffer.
Sourcepub fn init_with_data(&mut self, data: &NSData) -> Self
pub fn init_with_data(&mut self, data: &NSData) -> Self
Initializes a data object with the contents of another data object.
Sourcepub fn data_with_contents_of_file(path: &NSString) -> Self
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.
Sourcepub fn data_with_contents_of_file_options(
path: &NSString,
read_options_mask: NSDataReadingOptions,
) -> Result<Self, NSError>
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.
Sourcepub fn data_with_contents_of_url(url: &NSURL) -> Self
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.
Sourcepub fn data_with_contents_of_url_options(
url: &NSURL,
read_options_mask: NSDataReadingOptions,
) -> Result<Self, NSError>
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.
Sourcepub fn init_with_contents_of_file(&mut self, path: &NSString) -> Self
pub fn init_with_contents_of_file(&mut self, path: &NSString) -> Self
Initializes a data object with the content of the file at a given path.
Sourcepub fn init_with_contents_of_file_options(
&mut self,
path: &NSString,
read_options_mask: NSDataReadingOptions,
) -> Result<Self, NSError>
pub fn init_with_contents_of_file_options( &mut self, path: &NSString, read_options_mask: NSDataReadingOptions, ) -> Result<Self, NSError>
Initializes a data object with the content of the file at a given path.
Sourcepub fn init_with_contents_of_url(&mut self, url: &NSURL) -> Self
pub fn init_with_contents_of_url(&mut self, url: &NSURL) -> Self
Initializes a data object with the data from the location specified by a given URL.
Sourcepub fn init_with_contents_of_url_options(
&mut self,
url: &NSURL,
read_options_mask: NSDataReadingOptions,
) -> Result<Self, NSError>
pub fn init_with_contents_of_url_options( &mut self, url: &NSURL, read_options_mask: NSDataReadingOptions, ) -> Result<Self, NSError>
Initializes a data object with the data from the location specified by a given URL.
Sourcepub fn write_to_file_atomically(
&self,
path: &NSString,
use_auxiliary_file: bool,
) -> bool
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.
Sourcepub fn write_to_file_options(
&self,
path: &NSString,
write_options: NSDataWritingOptions,
) -> Result<bool, NSError>
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.
Sourcepub fn write_to_url_atomically(&self, url: &NSURL, atomically: bool) -> bool
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.
Sourcepub fn write_to_url_options(
&self,
url: &NSURL,
write_options: NSDataWritingOptions,
) -> Result<bool, NSError>
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.
Sourcepub fn init_with_base64_encoded_data_options(
&mut self,
base64_data: &NSData,
options: NSDataBase64DecodingOptions,
) -> Self
pub fn init_with_base64_encoded_data_options( &mut self, base64_data: &NSData, options: NSDataBase64DecodingOptions, ) -> Self
Initializes a data object with the given Base64 encoded data.
Sourcepub fn init_with_base64_encoded_string_options(
&mut self,
base64_string: &NSString,
options: NSDataBase64DecodingOptions,
) -> Self
pub fn init_with_base64_encoded_string_options( &mut self, base64_string: &NSString, options: NSDataBase64DecodingOptions, ) -> Self
Initializes a data object with the given Base64 encoded string.
Sourcepub fn base64_encoded_data_with_options(
&self,
options: NSDataBase64EncodingOptions,
) -> NSData
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.
Sourcepub fn base64_encoded_string_with_options(
&self,
options: NSDataBase64EncodingOptions,
) -> NSString
pub fn base64_encoded_string_with_options( &self, options: NSDataBase64EncodingOptions, ) -> NSString
Creates a Base64 encoded string from the string using the given options.
Sourcepub fn enumerate_byte_ranges_using_block<F>(&self, block: F)
pub fn enumerate_byte_ranges_using_block<F>(&self, block: F)
Enumerates each range of bytes in the data object using a block.
Sourcepub fn get_bytes_length(&self, buffer: *mut c_void, length: UInt)
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.
Sourcepub fn get_bytes_range(&self, buffer: *mut c_void, range: NSRange)
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.
Sourcepub fn subdata_with_range(&self, range: NSRange) -> NSData
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.
Sourcepub fn range_of_data_options_range(
&self,
data_to_find: &NSData,
mask: NSDataSearchOptions,
search_range: NSRange,
) -> NSRange
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.
Sourcepub fn is_equal_to_data(&self, other: &NSData) -> bool
pub fn is_equal_to_data(&self, other: &NSData) -> bool
Returns a Boolean value indicating whether this data object is the same as another.
Sourcepub fn compressed_data_using_algorithm(
&self,
algorithm: NSDataCompressionAlgorithm,
) -> Result<Self, NSError>
pub fn compressed_data_using_algorithm( &self, algorithm: NSDataCompressionAlgorithm, ) -> Result<Self, NSError>
Returns a new data object by compressing the data object’s bytes.
Sourcepub fn decompressed_data_using_algorithm(
&self,
algorithm: NSDataCompressionAlgorithm,
) -> Result<Self, NSError>
pub fn decompressed_data_using_algorithm( &self, algorithm: NSDataCompressionAlgorithm, ) -> Result<Self, NSError>
Returns a new data object by decompressing data object’s bytes.
Methods from Deref<Target = Object>§
Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
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 Twhere
T: Encode,
pub unsafe fn get_mut_ivar<T>(&mut self, name: &str) -> &mut Twhere
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
.