MxArray

Struct MxArray 

Source
pub struct MxArray(/* private fields */);
Expand description

The owned variant of an mxArray. Some of Matlab’s mex functions specify that the caller is responsible for deallocating the object when it is done with it, unless the object in question is returned to Matlab. This cannot be expressed with just (mutable) references, so this type implements the owned type.

It is basically a wrapper around a mutable reference to an mxArray, but it implements the drop trait, so when it is dropped it calls mxDestroyArray. It implements Deref and DerefMut, so it can also be used where-ever a (mutable) reference to an mxArray is expected.

Implementations§

Source§

impl MxArray

Source

pub unsafe fn assume_responsibility(mx: &'static mut mxArray_tag) -> MxArray

Create an MxArray by assuming responsibility for freeing an mxArray. Unless you have allocated an mxArray yourself, you do not need this.

Source

pub unsafe fn assume_responsibility_ptr(mx: *mut mxArray_tag) -> MxArray

Source

pub unsafe fn transfer_responsibility(o: MxArray) -> &'static mut mxArray_tag

Transfer responsibility for deallocating this mxArray back to Matlab. Unless you are manually calling raw matlab functions, you do not need this.

Source

pub unsafe fn transfer_responsibility_ptr(o: MxArray) -> *mut mxArray_tag

Methods from Deref<Target = mxArray_tag>§

Source

pub fn duplicate(&self) -> MxArray

Create a deep copy of the array, and return as an owned type. However, consider using MatlabClass::duplicate instead if you are already working with MatlabClasses.

Source

pub fn dimensions(&self) -> &[usize]

Return the sizes of the constituent dimensions of the mxArray

Source

pub fn numel(&self) -> usize

Return the number of elements contained in this array.

Source

pub fn raw_class_id(&self) -> u32

Return the raw class ID; the number Matlab returns.

Source

pub fn class_id(&self) -> Result<ClassID, u32>

Return Ok(ClassID) for mxArrays which map to a built-in class (such as numeric arrays, structure arrays, and cell arrays (see ClassID); otherwise it returns the raw class ID in the Err variant. These other values of the raw class ID are used in modern versions of Matlab for custom classes, defined via e..g classdef.

Source

pub fn is_complex(&self) -> bool

Check whether the backing array is complex. Since the only arrays which can be complex are numeric arrays, this also implies that.

Source

pub fn is_sparse(&self) -> bool

Check whether the backing array is a sparse matrix

Source

pub fn is_struct(&self) -> bool

Check whether the backing array is a struct array

Source

pub fn is_empty(&self) -> bool

Check whether the backing array is empty

Source

pub fn is_scalar(&self) -> bool

Check whether the backing array only holds one element

Source

pub fn complexity(&self) -> Complexity

Trait Implementations§

Source§

impl AsRef<mxArray_tag> for MxArray

Source§

fn as_ref(&self) -> &mxArray_tag

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<mxArray_tag> for MxArray

Source§

fn borrow(&self) -> &mxArray_tag

Immutably borrows from an owned value. Read more
Source§

impl Clone for MxArray

Source§

fn clone(&self) -> MxArray

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

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

Performs copy-assignment from source. Read more
Source§

impl Debug for MxArray

Source§

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

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

impl Deref for MxArray

Source§

type Target = mxArray_tag

The resulting type after dereferencing.
Source§

fn deref(&self) -> &<MxArray as Deref>::Target

Dereferences the value.
Source§

impl DerefMut for MxArray

Source§

fn deref_mut(&mut self) -> &mut <MxArray as Deref>::Target

Mutably dereferences the value.
Source§

impl Drop for MxArray

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl MatlabPtr for MxArray

Source§

fn is_a<W>(self) -> Result<W, FromMatlabError<Self>>
where W: MatlabClass<Self>, Self: Sized,

A MatlabPtr is an untyped pointer; it does not know what the type of the data it holds is. However, Rustmex provides types which represent that information. If the MatlabPtr holds one of those data types, “upcast” the pointer to that type and return it.

Auto Trait Implementations§

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, 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.
Source§

impl<T> MutMatlabPtr for T
where T: DerefMut<Target = mxArray_tag> + MatlabPtr,