Struct objc2::foundation::NSMutableData
source · #[repr(C)]pub struct NSMutableData { /* private fields */ }
Expand description
Implementations§
source§impl NSMutableData
impl NSMutableData
Creation methods
source§impl NSMutableData
impl NSMutableData
Mutation methods
Methods from Deref<Target = NSData>§
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn bytes(&self) -> &[u8] ⓘ
Methods from Deref<Target = NSObject>§
sourcepub fn is_kind_of<T: ClassType>(&self) -> bool
pub fn is_kind_of<T: ClassType>(&self) -> bool
Check if the object is an instance of the class, or one of it’s subclasses.
See Apple’s documentation for more details on what you may (and what you may not) do with this information.
Methods from Deref<Target = Object>§
sourcepub unsafe fn ivar_ptr<T: Encode>(&self, name: &str) -> *mut T
pub unsafe fn ivar_ptr<T: Encode>(&self, name: &str) -> *mut T
Returns a pointer to the instance variable / ivar with the given name.
This is similar to UnsafeCell::get
, see that for more information
on what is and isn’t safe to do.
Usually you will have defined the instance variable yourself with
ClassBuilder::add_ivar
, the type of the ivar T
must match the
type used in that.
Attempting to access or modify private implementation details of a class that you do no control using this is not supported, and may invoke undefined behaviour.
Library implementors are strongly encouraged to expose a safe interface to the ivar.
Panics
May panic if the object has no ivar with the given name. May also
panic if the type encoding of the ivar differs from the type encoding
of T
.
This should purely seen as help while debugging and is not guaranteed
(e.g. it may be disabled when debug_assertions
are off).
Safety
The object must have an instance variable with the given name, and it
must be of type T
. Any invariants that the object have assumed about
the value of the instance variable must not be violated.
No thread syncronization is done on accesses to the variable, so you must ensure that any access to the returned pointer do not cause data races, and that Rust’s mutability rules are not otherwise violated.
sourcepub unsafe fn ivar<T: Encode>(&self, name: &str) -> &T
pub unsafe fn ivar<T: Encode>(&self, name: &str) -> &T
Returns a reference to the instance variable with the given name.
See Object::ivar_ptr
for more information, including on when this
panics.
Safety
The object must have an instance variable with the given name, and it
must be of type T
.
No thread syncronization is done, so you must ensure that no other
thread is concurrently mutating the variable. This requirement can be
considered upheld if all mutation happens through Object::ivar_mut
(since that takes &mut self
).
sourcepub unsafe fn get_ivar<T: Encode>(&self, name: &str) -> &T
👎Deprecated: Use Object::ivar
instead.
pub unsafe fn get_ivar<T: Encode>(&self, name: &str) -> &T
Object::ivar
instead.sourcepub unsafe fn ivar_mut<T: Encode>(&mut self, name: &str) -> &mut T
pub unsafe fn ivar_mut<T: Encode>(&mut self, name: &str) -> &mut T
Returns a mutable reference to the ivar with the given name.
See Object::ivar_ptr
for more information, including on when this
panics.
Safety
The object must have an instance variable with the given name, and it
must be of type T
.
This access happens through &mut self
, which means we know it to be
the only reference, hence you do not need to do any work to ensure
that data races do not happen.
sourcepub unsafe fn get_mut_ivar<T: Encode>(&mut self, name: &str) -> &mut T
👎Deprecated: Use Object::ivar_mut
instead.
pub unsafe fn get_mut_ivar<T: Encode>(&mut self, name: &str) -> &mut T
Object::ivar_mut
instead.sourcepub unsafe fn set_ivar<T: Encode>(&mut self, name: &str, value: T)
pub unsafe fn set_ivar<T: Encode>(&mut self, name: &str, value: T)
Sets the value of the ivar with the given name.
This is just a helpful shorthand for Object::ivar_mut
, see that
for more information.
Safety
Same as Object::ivar_mut
.
Trait Implementations§
source§impl AsMut<[u8]> for NSMutableData
impl AsMut<[u8]> for NSMutableData
source§impl AsMut<NSData> for NSMutableData
impl AsMut<NSData> for NSMutableData
source§impl AsMut<NSMutableData> for NSMutableData
impl AsMut<NSMutableData> for NSMutableData
source§impl AsMut<NSObject> for NSMutableData
impl AsMut<NSObject> for NSMutableData
source§impl AsMut<Object> for NSMutableData
impl AsMut<Object> for NSMutableData
source§impl AsRef<[u8]> for NSMutableData
impl AsRef<[u8]> for NSMutableData
source§impl AsRef<NSData> for NSMutableData
impl AsRef<NSData> for NSMutableData
source§impl AsRef<NSMutableData> for NSMutableData
impl AsRef<NSMutableData> for NSMutableData
source§impl AsRef<NSObject> for NSMutableData
impl AsRef<NSObject> for NSMutableData
source§impl AsRef<Object> for NSMutableData
impl AsRef<Object> for NSMutableData
source§impl Borrow<NSData> for NSMutableData
impl Borrow<NSData> for NSMutableData
source§impl Borrow<NSObject> for NSMutableData
impl Borrow<NSObject> for NSMutableData
source§impl Borrow<Object> for NSMutableData
impl Borrow<Object> for NSMutableData
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
source§impl BorrowMut<NSObject> for NSMutableData
impl BorrowMut<NSObject> for NSMutableData
source§fn borrow_mut(&mut self) -> &mut NSObject
fn borrow_mut(&mut self) -> &mut NSObject
source§impl BorrowMut<Object> for NSMutableData
impl BorrowMut<Object> for NSMutableData
source§fn borrow_mut(&mut self) -> &mut Object
fn borrow_mut(&mut self) -> &mut Object
source§impl ClassType for NSMutableData
impl ClassType for NSMutableData
source§impl Debug for NSMutableData
impl Debug for NSMutableData
source§impl DefaultId for NSMutableData
impl DefaultId for NSMutableData
source§impl Deref for NSMutableData
impl Deref for NSMutableData
source§impl DerefMut for NSMutableData
impl DerefMut for NSMutableData
source§impl<'a> Extend<&'a u8> for NSMutableData
impl<'a> Extend<&'a u8> for NSMutableData
source§fn extend<T: IntoIterator<Item = &'a u8>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = &'a u8>>(&mut self, iter: T)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl Extend<u8> for NSMutableData
impl Extend<u8> for NSMutableData
source§fn extend<T: IntoIterator<Item = u8>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = u8>>(&mut self, iter: T)
You should use extend_from_slice
whenever possible, it is more
performant.
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl Hash for NSMutableData
impl Hash for NSMutableData
source§impl<I: SliceIndex<[u8]>> Index<I> for NSMutableData
impl<I: SliceIndex<[u8]>> Index<I> for NSMutableData
source§impl<I: SliceIndex<[u8]>> IndexMut<I> for NSMutableData
impl<I: SliceIndex<[u8]>> IndexMut<I> for NSMutableData
source§impl<'a> IntoIterator for &'a NSMutableData
impl<'a> IntoIterator for &'a NSMutableData
source§impl<'a> IntoIterator for &'a mut NSMutableData
impl<'a> IntoIterator for &'a mut NSMutableData
source§impl NSCopying for NSMutableData
impl NSCopying for NSMutableData
source§impl NSMutableCopying for NSMutableData
impl NSMutableCopying for NSMutableData
§type Output = NSMutableData
type Output = NSMutableData
fn mutable_copy(&self) -> Id<Self::Output, Owned> ⓘ
source§impl PartialEq<NSMutableData> for NSMutableData
impl PartialEq<NSMutableData> for NSMutableData
source§fn eq(&self, other: &NSMutableData) -> bool
fn eq(&self, other: &NSMutableData) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl RefEncode for NSMutableData
impl RefEncode for NSMutableData
source§const ENCODING_REF: Encoding = <NSData as crate::RefEncode>::ENCODING_REF
const ENCODING_REF: Encoding = <NSData as crate::RefEncode>::ENCODING_REF
source§impl ToOwned for NSMutableData
impl ToOwned for NSMutableData
§type Owned = Id<NSMutableData, Owned>
type Owned = Id<NSMutableData, Owned>
source§fn to_owned(&self) -> Self::Owned
fn to_owned(&self) -> Self::Owned
1.63.0 · source§fn clone_into(&self, target: &mut Self::Owned)
fn clone_into(&self, target: &mut Self::Owned)
source§impl Write for NSMutableData
impl Write for NSMutableData
source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
source§fn write_all(&mut self, buf: &[u8]) -> Result<()>
fn write_all(&mut self, buf: &[u8]) -> Result<()>
source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)