Bindings and derivable traits
We've encountered several traits that shouldn't be implemented manually, but derived. These traits express connections between types in Rust and Julia and their properties.
The following traits can currently be derived:
-
ValidLayout
Expresses that the implementor represents the layout of one or more Julia types, i.e. it's a layout type. -
ValidField
Expresses that the implementor represents the layout of one or more Julia types when used as a field of another type. -
IsBits
Expresses that the implementor is the layout of anisbits
type. -
Typecheck
Lets the implementor be used withDataType::is
andValue::is
, the implementation callsValidLayout::valid_layout
. -
IntoJulia
Lets the implementor be converted to managed data withValue::new
. -
Unbox
Lets the implementor be used as the target type ofValue::unbox
. -
ConstructType
Lets the implementor be used as a type constructor. -
HasLayout
Links a type constructor to its layout type. -
CCallArg
Lets the implementor be used as an argument type of a function called viaccall
. -
CCallReturn
Lets the implementor be used as the return type of a function called viaccall
. -
Enum
Maps the implementor to a Julia enum.
We can use JlrsCore.jl to generate bindings to Julia types which derive these traits if applicable. These bindings provide an interface to existing Julia types, and can't be used to expose Rust types to Julia.