Expand description
TypeRef → syn::Type mapping with unified position-based system.
Follows the wasm-bindgen WebIDL approach: a single to_syn_type function
that uses TypePosition to determine how types are lowered to Rust.
TypePosition is a struct with two fields:
direction:ArgumentorReturn— controls borrowing (e.g.,&strvsString)inner: whether we’re nested inside a generic container (e.g.,Promise<T>)
When inner is true:
- Primitives map to JS wrapper types (
Number,JsString,Boolean,Undefined) NullablebecomesJsOption<T>instead ofOption<T>- Argument-position types are NOT borrowed (owned
T, not&T)
Structs§
- Codegen
Context - Context for codegen that tracks locally-defined types and resolved type aliases.
- Type
Position - Position context for type mapping, following the wasm-bindgen WebIDL pattern.
Enums§
- Direction
- Direction of data flow at the FFI boundary.
Constants§
- JS_
SYS_ RESERVED - js_sys type names reserved by the
use js_sys::*glob import. User-defined types that collide with these will be renamed.
Functions§
- to_
return_ type - Map an IR
TypeRefto the type used in a wasm_bindgen return position, wrapping inResult<T, JsValue>whencatchis true. - to_
syn_ type - Map an IR
TypeRefto aproc_macro2::TokenStreamrepresenting the Rust type.