Main Content

coder.RustWrapper.genRustBindings

Create Rust bindings for C code generated from Simulink models

Since R2026a

Description

Add-On Required: This feature requires the Simulink Support Package for Rust Code add-on.

coder.RustWrapper.genRustBindings(buildInfo) generates Rust® bindings for the C code produced from the Simulink® model associated with the specified buildInfo object.

example

coder.RustWrapper.genRustBindings(buildInfo,Name=Value) specifies options using one or more name-value arguments in addition to the input arguments. For example, set PackageType to "lib" to generate a Rust library package, or to "bin" to generate an executable Rust package.

example

Examples

collapse all

Generate a Rust library package for C code generated from the Simulink model ex_if_else_SL in a custom folder.

open_system("ex_if_else_SL");
slbuild("ex_if_else_SL");
bi=load(fullfile("ex_if_else_SL_ert_rtw", "buildInfo.mat"));
coder.RustWrapper.genRustBindings(bi.buildInfo,PackageType="lib",OutDirPath="C:\rust\bindings");

PackageType controls the type of Rust package generated. OutDirPath controls the folder where the function writes the generated Rust bindings. If you do not specify these name-value arguments, the function uses the build information bi.buildInfo to generate Rust bindings for the C code and writes them to the rust_bindings folder, which the function creates at the same level as the build folder of the model. For more information on generating Rust bindings using coder.RustWrapper.genRustBindings, including prerequisites and setup, see Generate Rust Bindings for Simulink Generated C Code and Install Simulink Support Package for Rust Code.

Input Arguments

collapse all

Build information for compiling and linking generated code, specified as an RTW.BuildInfo object.

Name-Value Arguments

collapse all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: coder.RustWrapper.genRustBindings(buildInfo,PackageType="bin",OutDirPath="C:\rust\bindings")

Specify the type of Rust package to generate. Use "lib" to generate a library package or "bin" to generate a binary package.

Example: PackageType="lib"

Folder where the function writes the generated Rust bindings, specified as a character vector or string scalar. By default, the function writes the bindings to rust_bindings folder in the current working folder.

Example: OutDirPath="C:\rust\bindings"

Version History

Introduced in R2026a