Struct objc2_foundation::NSData
source · #[repr(C)]pub struct NSData { /* private fields */ }
Available on crate feature
NSData
only.Implementations§
source§impl NSData
impl NSData
NSExtendedData
pub unsafe fn description(&self) -> Retained<NSString>
Available on crate feature
NSString
only.pub unsafe fn getBytes_length( &self, buffer: NonNull<c_void>, length: NSUInteger )
pub unsafe fn getBytes_range(&self, buffer: NonNull<c_void>, range: NSRange)
Available on crate feature
NSRange
only.pub unsafe fn isEqualToData(&self, other: &NSData) -> bool
pub unsafe fn subdataWithRange(&self, range: NSRange) -> Retained<NSData>
Available on crate feature
NSRange
only.pub unsafe fn writeToFile_atomically( &self, path: &NSString, use_auxiliary_file: bool ) -> bool
Available on crate feature
NSString
only.pub unsafe fn writeToURL_atomically( &self, url: &NSURL, atomically: bool ) -> bool
Available on crate feature
NSURL
only.pub unsafe fn writeToFile_options_error( &self, path: &NSString, write_options_mask: NSDataWritingOptions ) -> Result<(), Retained<NSError>>
Available on crate features
NSError
and NSString
only.pub unsafe fn writeToURL_options_error( &self, url: &NSURL, write_options_mask: NSDataWritingOptions ) -> Result<(), Retained<NSError>>
Available on crate features
NSError
and NSURL
only.pub unsafe fn rangeOfData_options_range( &self, data_to_find: &NSData, mask: NSDataSearchOptions, search_range: NSRange ) -> NSRange
Available on crate feature
NSRange
only.pub unsafe fn enumerateByteRangesUsingBlock( &self, block: &Block<dyn Fn(NonNull<c_void>, NSRange, NonNull<Bool>) + '_> )
Available on crate features
NSRange
and block2
only.source§impl NSData
impl NSData
NSDataCreation
pub unsafe fn data() -> Retained<Self>
pub unsafe fn dataWithBytes_length( bytes: *mut c_void, length: NSUInteger ) -> Retained<Self>
pub unsafe fn dataWithBytesNoCopy_length( bytes: NonNull<c_void>, length: NSUInteger ) -> Retained<Self>
pub unsafe fn dataWithBytesNoCopy_length_freeWhenDone( bytes: NonNull<c_void>, length: NSUInteger, b: bool ) -> Retained<Self>
pub unsafe fn dataWithContentsOfFile_options_error( path: &NSString, read_options_mask: NSDataReadingOptions ) -> Result<Retained<Self>, Retained<NSError>>
Available on crate features
NSError
and NSString
only.pub unsafe fn dataWithContentsOfURL_options_error( url: &NSURL, read_options_mask: NSDataReadingOptions ) -> Result<Retained<Self>, Retained<NSError>>
Available on crate features
NSError
and NSURL
only.pub unsafe fn dataWithContentsOfFile(path: &NSString) -> Option<Retained<Self>>
Available on crate feature
NSString
only.pub unsafe fn dataWithContentsOfURL(url: &NSURL) -> Option<Retained<Self>>
Available on crate feature
NSURL
only.pub unsafe fn initWithBytes_length( this: Allocated<Self>, bytes: *mut c_void, length: NSUInteger ) -> Retained<Self>
pub unsafe fn initWithBytesNoCopy_length( this: Allocated<Self>, bytes: NonNull<c_void>, length: NSUInteger ) -> Retained<Self>
pub unsafe fn initWithBytesNoCopy_length_freeWhenDone( this: Allocated<Self>, bytes: NonNull<c_void>, length: NSUInteger, b: bool ) -> Retained<Self>
pub unsafe fn initWithBytesNoCopy_length_deallocator( this: Allocated<Self>, bytes: NonNull<c_void>, length: NSUInteger, deallocator: Option<&Block<dyn Fn(NonNull<c_void>, NSUInteger)>> ) -> Retained<Self>
Available on crate feature
block2
only.pub unsafe fn initWithContentsOfFile_options_error( this: Allocated<Self>, path: &NSString, read_options_mask: NSDataReadingOptions ) -> Result<Retained<Self>, Retained<NSError>>
Available on crate features
NSError
and NSString
only.pub unsafe fn initWithContentsOfURL_options_error( this: Allocated<Self>, url: &NSURL, read_options_mask: NSDataReadingOptions ) -> Result<Retained<Self>, Retained<NSError>>
Available on crate features
NSError
and NSURL
only.pub unsafe fn initWithContentsOfFile( this: Allocated<Self>, path: &NSString ) -> Option<Retained<Self>>
Available on crate feature
NSString
only.pub unsafe fn initWithContentsOfURL( this: Allocated<Self>, url: &NSURL ) -> Option<Retained<Self>>
Available on crate feature
NSURL
only.pub fn initWithData(this: Allocated<Self>, data: &NSData) -> Retained<Self>
pub fn dataWithData(data: &NSData) -> Retained<Self>
source§impl NSData
impl NSData
NSDataBase64Encoding
pub unsafe fn initWithBase64EncodedString_options( this: Allocated<Self>, base64_string: &NSString, options: NSDataBase64DecodingOptions ) -> Option<Retained<Self>>
Available on crate feature
NSString
only.pub unsafe fn base64EncodedStringWithOptions( &self, options: NSDataBase64EncodingOptions ) -> Retained<NSString>
Available on crate feature
NSString
only.pub unsafe fn initWithBase64EncodedData_options( this: Allocated<Self>, base64_data: &NSData, options: NSDataBase64DecodingOptions ) -> Option<Retained<Self>>
pub unsafe fn base64EncodedDataWithOptions( &self, options: NSDataBase64EncodingOptions ) -> Retained<NSData>
source§impl NSData
impl NSData
NSDataCompression
pub unsafe fn decompressedDataUsingAlgorithm_error( &self, algorithm: NSDataCompressionAlgorithm ) -> Result<Retained<Self>, Retained<NSError>>
Available on crate feature
NSError
only.pub unsafe fn compressedDataUsingAlgorithm_error( &self, algorithm: NSDataCompressionAlgorithm ) -> Result<Retained<Self>, Retained<NSError>>
Available on crate feature
NSError
only.source§impl NSData
impl NSData
NSDeprecated
pub unsafe fn getBytes(&self, buffer: NonNull<c_void>)
👎Deprecated: This method is unsafe because it could potentially cause buffer overruns. Use -getBytes:length: instead.
pub unsafe fn dataWithContentsOfMappedFile( path: &NSString ) -> Option<Retained<AnyObject>>
👎Deprecated: Use +dataWithContentsOfURL:options:error: and NSDataReadingMappedIfSafe or NSDataReadingMappedAlways instead.
Available on crate feature
NSString
only.pub unsafe fn initWithContentsOfMappedFile( this: Allocated<Self>, path: &NSString ) -> Option<Retained<Self>>
👎Deprecated: Use -initWithContentsOfURL:options:error: and NSDataReadingMappedIfSafe or NSDataReadingMappedAlways instead.
Available on crate feature
NSString
only.pub unsafe fn initWithBase64Encoding( this: Allocated<Self>, base64_string: &NSString ) -> Option<Retained<Self>>
👎Deprecated: Use initWithBase64EncodedString:options: instead
Available on crate feature
NSString
only.pub unsafe fn base64Encoding(&self) -> Retained<NSString>
👎Deprecated: Use base64EncodedStringWithOptions: instead
Available on crate feature
NSString
only.Methods from Deref<Target = NSObject>§
sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
sourcepub fn class(&self) -> &'static AnyClass
pub fn class(&self) -> &'static AnyClass
Dynamically find the class of this object.
§Example
Check that an instance of NSObject
has the precise class NSObject
.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());
sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load
instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load
instead.Use Ivar::load
instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T
.
See Ivar::load_ptr
for details surrounding this.
sourcepub unsafe fn get_mut_ivar<T>(&mut self, name: &str) -> &mut Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load_mut
instead.
pub unsafe fn get_mut_ivar<T>(&mut self, name: &str) -> &mut Twhere
T: Encode,
Ivar::load_mut
instead.Use Ivar::load_mut
instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T
.
See Ivar::load_ptr
for details surrounding this.
Trait Implementations§
source§impl AsMut<NSData> for NSMutableData
impl AsMut<NSData> for NSMutableData
source§impl AsMut<NSData> for NSPurgeableData
impl AsMut<NSData> for NSPurgeableData
source§impl AsRef<NSData> for NSMutableData
impl AsRef<NSData> for NSMutableData
source§impl AsRef<NSData> for NSPurgeableData
impl AsRef<NSData> for NSPurgeableData
source§impl Borrow<NSData> for NSMutableData
impl Borrow<NSData> for NSMutableData
source§impl Borrow<NSData> for NSPurgeableData
impl Borrow<NSData> for NSPurgeableData
source§impl BorrowMut<AnyObject> for NSData
impl BorrowMut<AnyObject> for NSData
source§fn borrow_mut(&mut self) -> &mut AnyObject
fn borrow_mut(&mut self) -> &mut AnyObject
Mutably borrows from an owned value. Read more
source§impl BorrowMut<NSData> for NSMutableData
impl BorrowMut<NSData> for NSMutableData
source§fn borrow_mut(&mut self) -> &mut NSData
fn borrow_mut(&mut self) -> &mut NSData
Mutably borrows from an owned value. Read more
source§impl BorrowMut<NSData> for NSPurgeableData
impl BorrowMut<NSData> for NSPurgeableData
source§fn borrow_mut(&mut self) -> &mut NSData
fn borrow_mut(&mut self) -> &mut NSData
Mutably borrows from an owned value. Read more
source§impl BorrowMut<NSObject> for NSData
impl BorrowMut<NSObject> for NSData
source§fn borrow_mut(&mut self) -> &mut NSObject
fn borrow_mut(&mut self) -> &mut NSObject
Mutably borrows from an owned value. Read more
source§impl ClassType for NSData
impl ClassType for NSData
§type Mutability = ImmutableWithMutableSubclass<NSMutableData>
type Mutability = ImmutableWithMutableSubclass<NSMutableData>
Whether the type is mutable or immutable. Read more
source§const NAME: &'static str = "NSData"
const NAME: &'static str = "NSData"
The name of the Objective-C class that this type represents. Read more
source§fn class() -> &'static AnyClass
fn class() -> &'static AnyClass
Get a reference to the Objective-C class that this type represents. Read more
source§fn as_super_mut(&mut self) -> &mut Self::Super
fn as_super_mut(&mut self) -> &mut Self::Super
Get a mutable reference to the superclass.
source§impl DefaultRetained for NSData
impl DefaultRetained for NSData
source§impl<'a> IntoIterator for &'a NSData
impl<'a> IntoIterator for &'a NSData
source§impl NSCopying for NSData
Available on crate feature NSObject
only.
impl NSCopying for NSData
Available on crate feature
NSObject
only.source§impl NSMutableCopying for NSData
Available on crate feature NSObject
only.
impl NSMutableCopying for NSData
Available on crate feature
NSObject
only.source§impl NSObjectProtocol for NSData
impl NSObjectProtocol for NSData
source§fn isEqual(&self, other: &AnyObject) -> bool
fn isEqual(&self, other: &AnyObject) -> bool
Check whether the object is equal to an arbitrary other object. Read more
source§fn hash(&self) -> usize
fn hash(&self) -> usize
An integer that can be used as a table address in a hash table
structure. Read more
source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Check if the object is an instance of the class, or one of its
subclasses. Read more
source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
Check if the object is an instance of the class type, or one of its
subclasses. Read more
source§fn isMemberOfClass(&self, cls: &AnyClass) -> bool
fn isMemberOfClass(&self, cls: &AnyClass) -> bool
Check if the object is an instance of a specific class, without
checking subclasses. Read more
source§fn respondsToSelector(&self, aSelector: Sel) -> bool
fn respondsToSelector(&self, aSelector: Sel) -> bool
Check whether the object implements or inherits a method with the
given selector. Read more
source§fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
fn conformsToProtocol(&self, aProtocol: &AnyProtocol) -> bool
Check whether the object conforms to a given protocol. Read more
source§fn debugDescription(&self) -> Retained<NSObject>
fn debugDescription(&self) -> Retained<NSObject>
A textual representation of the object to use when debugging. Read more
source§impl NSSecureCoding for NSData
Available on crate feature NSObject
only.
impl NSSecureCoding for NSData
Available on crate feature
NSObject
only.source§impl PartialEq for NSData
impl PartialEq for NSData
source§impl RefEncode for NSData
impl RefEncode for NSData
source§const ENCODING_REF: Encoding = <NSObject as ::objc2::RefEncode>::ENCODING_REF
const ENCODING_REF: Encoding = <NSObject as ::objc2::RefEncode>::ENCODING_REF
The Objective-C type-encoding for a reference of this type. Read more
source§impl RetainedFromIterator<u8> for NSData
Available on crate feature block2
only.
impl RetainedFromIterator<u8> for NSData
Available on crate feature
block2
only.source§fn id_from_iter<I: IntoIterator<Item = u8>>(iter: I) -> Retained<Self>
fn id_from_iter<I: IntoIterator<Item = u8>>(iter: I) -> Retained<Self>
Creates an
Retained
from an iterator. Read moresource§fn retained_from_iter<I>(iter: I) -> Retained<Self>where
I: IntoIterator<Item = T>,
fn retained_from_iter<I>(iter: I) -> Retained<Self>where
I: IntoIterator<Item = T>,
Creates an
Retained
from an iterator.source§impl ToOwned for NSData
Available on crate feature NSObject
only.
impl ToOwned for NSData
Available on crate feature
NSObject
only.impl Eq for NSData
impl Message for NSData
impl RefUnwindSafe for NSData
impl Send for NSData
impl StructuralPartialEq for NSData
impl Sync for NSData
impl UnwindSafe for NSData
Auto Trait Implementations§
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CounterpartOrSelf for T
impl<T> CounterpartOrSelf for T
§type Immutable = <<T as ClassType>::Mutability as MutabilityCounterpartOrSelf<T>>::Immutable
type Immutable = <<T as ClassType>::Mutability as MutabilityCounterpartOrSelf<T>>::Immutable
The immutable counterpart of the type, or
Self
if the type has no
immutable counterpart. Read more§type Mutable = <<T as ClassType>::Mutability as MutabilityCounterpartOrSelf<T>>::Mutable
type Mutable = <<T as ClassType>::Mutability as MutabilityCounterpartOrSelf<T>>::Mutable
The mutable counterpart of the type, or
Self
if the type has no
mutable counterpart. Read more