Type Mappings

Every Rust type is automatically mapped to its TypeScript equivalent during code generation. Here's the complete reference.

RustTypeScriptNotes
String, &str, charstring
i8i128, u8u128, f32, f64numberor bigint via bigint_types
boolboolean
()voidno-input procedures
Vec<T>, HashSet<T>, BTreeSet<T>T[]also Array<T> in generic positions
Option<T>T | nullwith serde(default): field?: T | null
HashMap<K, V>, BTreeMap<K, V>Record<K, V>
Box<T>, Arc<T>, Rc<T>, Cow<T>Ttransparent unwrap
(A, B, C)[A, B, C]tuples
[T; N]T[]fixed-size arrays
Result<T, E>TOk(T) unwrapped; Err(E) serialized as JSON and thrown as RpcError (status 500)
structinterface
enum (unit variants)"A" | "B"string union
enum (data variants){ A: T } | ...see Serde Support for tagging
Newtype struct Id(String)type Id = stringor branded with branded_newtypes

Try it

A single struct with every mapping from the table above. Click Fetch to see live values.

visit GitHub to learn more about metaxy