Expand description
Safe, lifetime-aware Rust bindings for MATLAB’s Matrix, MEX and MAT-file APIs.
The safe API has three ownership categories: OwnedArray is destroyed by
Rust, ArrayRef is a read-only borrow, and WorkspaceValue is a
MATLAB workspace pointer valid until the next MATLAB callback.
Modules§
- api_
coverage - Function-by-function coverage of the R2025a API-800 C headers.
- error_
handling - Error propagation guarantees and unavoidable native termination cases.
- raw
- Unsafe one-to-one escape hatches for published API-800 operations.
Macros§
- error_
id - Create an
ErrorIdfrom a string literal, validated at compile time. - mex_
entrypoint - Export a MEX entrypoint for fixed inputs, or use
dynamicforDynInputs.
Structs§
- Array
Info - Owned metadata-only array header returned by a MAT-file info operation.
It intentionally cannot become an
ArrayRefbecause MATLAB stores non-dereferenceable sentinels in its data pointers. - Array
Mut - An exclusive array view. Child and data borrows are tied to each method call.
- Array
Ref - A read-only view. It can neither be destroyed nor transferred to MATLAB.
- Complex
- Interleaved complex values shared with Rust numerical crates. A complex number in Cartesian form.
- DynInputs
- Read-only MEX inputs with a variable argument count.
Use
mex_entrypoint!(handler, dynamic)for a dynamic handler. - Error
- An error that preserves the native operation and MATLAB error status.
- ErrorId
- A validated MATLAB exception identifier of at most 255 ASCII bytes.
- File
Stream - Restricted diagnostic view of a MAT-file’s underlying C stream.
- Inputs
- Exactly
Nread-only MEX inputs, checked before the handler runs. - MatError
- An unmodified error code from
matGetErrno(not an OS errno). - MatFile
- Owned
MATFilehandle tied to the current MEX invocation. - Matlab
- A generative proof of the current MATLAB invocation and thread.
- Matlab
Error Info - Identifier and message copied from a trapped MATLAB callback exception. This does not include the exception’s stack or nested causes.
- Module
Lock - One counted lock on the current MEX module.
- MxBuffer
- A byte buffer allocated by MATLAB’s memory manager. It is initialized by
mxCallocand is always released with the matchingmxFree. - Named
- A MAT-file value paired with its variable name.
- Outputs
- MEX output slots that accept ownership of Rust-created arrays.
- Owned
Array - A uniquely owned MATLAB array. The invariant brand prevents it from escaping
the MEX invocation that created it. Drop calls
mxDestroyArrayexactly once. - Persistent
Array - A MATLAB-persistent array handle that may be stored between MEX calls.
- Plain
Array Ref - A primitive MATLAB array whose MAT-file serialization does not invoke user-defined MATLAB code. Cell, struct, string, and object arrays are excluded.
- Sparse
Indices - Validated compressed-column indices borrowed from a sparse array.
- Uninit
Numeric - An allocated numeric array that cannot be read or transferred until filled.
- Variable
Infos - Sequential iterator over variable headers in a MAT-file.
- Variables
- Sequential iterator over complete variables in a MAT-file.
- Workspace
Scope - A workspace access period.
WorkspaceScope::callconsumes it and the supplied workspace values before invoking MATLAB. - Workspace
Value - A pointer returned by
mexGetVariablePtr. It can be read until it is consumed byWorkspaceScope::callor dropped.
Enums§
- Call
Input - One MATLAB callback input, either an ordinary view or a consumed workspace
pointer. Use
into()to assemble a mixed argument list. - Class
- MATLAB’s stable matrix class identifiers.
- Error
Kind - Failures distinguished without guessing undocumented native error numbers.
- MatVersion
- All creation formats accepted by
matOpen. - Open
Mode - Access mode for a MAT-file.
- Workspace
- MATLAB’s three workspace namespaces.
Traits§
- Numeric
- A Rust element with exactly the layout used by an API-800 numeric array.
- Result
Ext - Attach an exception identifier or context to a
Resultwithout losing its cause. - Sparse
Numeric - A numeric element supported by MATLAB’s published sparse constructor.
Functions§
- eps
- Return MATLAB’s floating-point epsilon constant.
- inf
- Return MATLAB’s positive infinity constant.
- is_
finite - Test a floating-point value with MATLAB’s finite predicate.
- is_inf
- Test a floating-point value with MATLAB’s infinity predicate.
- is_nan
- Test a floating-point value with MATLAB’s NaN predicate.
- nan
- Return MATLAB’s quiet NaN constant.
Type Aliases§
- Result
- Result type used by the safe API.