Crate rustmex

source ·
Expand description

Rustmex: A library providing convenient Rust bindings to Matlab’s MEX C api.

Rustmex makes writing MEX functions in Rust a bit easier. It convert Matlab types, and the arguments it provides to mexFunction into more Rusty types, which can then be used to interface with other Rust code easily.

For installation instructions, see the backend module.

Re-exports

Modules

  • Allocation related functionality
  • Backends and Installation
  • Cell arrays
  • Character arrays
  • Convert directly to and from matlab pointers
  • Functions and function handles for calling back to Matlab
  • Array indexing functionality
  • Create and send Matlab warning and error messages
  • Numeric data classes
  • Matlab object arrays/custom classes
  • As is convention in Rust, Rustmex defines a prelude to easily import often used functionality.
  • Structures and structure arrays
  • Workspace related functions

Macros

  • Check some boolean condition; if it is not met, return an Err(Error) with the given id and message. Can be used within functions which return a rustmex::Result.
  • Unconditionally return a rustmex::Result with the error variant, set with an id and a message. Useful when the error condition has already been checked in some other way.
  • Check some boolean condition, if it is met, return an Err(Error) with the given id and message. Can be used within functions which return a rustmex::Result.
  • Trigger a Matlab error

Structs

  • A complex number in Cartesian form.
  • Error converting from matlab. Stores the unconverted data, allowing it to be reused, especially for owned data.
  • 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.

Traits

  • Base Matlab class trait. Matlab classes, in Rustmex, are wrapper structures around a bare MatlabPtr, giving them some type information.
  • Denotes whether the Matlab class is mutable.
  • Some, but not all types, can be created in an empty state; whether they can is denoted by this trait.
  • Denotes whether a Matlab class owns its data.
  • Only some Matlab classes, i.e the numeric classes, have data that can be meaningfully taken out of the backing MutMatlabPtr.

Functions

  • Generate an ad-hoc warning from an id and a message

Type Definitions

  • The “left hand side” of a call to a mex function. In this slice, the return values should be placed.
  • Convenience type for returning a Error containing a MexMessage in the error path.
  • The “Right hand side” of a call to a mex function. These are the arguments provided to it in matlab.
  • The main matlab opaque array type, returned and accepted as argument by various mex functions.

Attribute Macros

  • Re-export the macro to annotate the entry point.