[][src]Module jlrs::traits

All traits used by this crate.

Most of these traits are intended for internal use only and you should never manually implement them for your own types nor call any of their trait methods directly.

The one major exception is the Frame trait. This trait is implemented by the two frame types that are provided, StaticFrame and DynamicFrame which are used to ensure the garbage collector doesn't drop the data that's used from Rust. It provides the common functionality these frame types offer.

Two of the traits in this module are available as custom derive traits, JuliaStruct and IntoJulia, which can be used to map a struct between Julia and Rust. Deriving the first will implement JuliaType, JuliaTypecheck, ValidLayout, and Cast, which will let you safely access the raw contents of a value; IntoJulia can be derived for bits types and lets you create new instances of that type using Value::new. While it's possible to manually implement and annotate these mapping structs, you should use JlrsReflect.jl which can generate these structs for you. If you do want to do this manually, see the documentation of JuliaStruct for instructions.

Traits

Align

Trait implemented by the aligning structs, which ensure bits unions are properly aligned. Used in combination with BitsUnion and Flag to ensure bits unions are inserted correctly.

BitsUnion

Trait implemented by structs that can contain a bits union. Used in combination with Align and Flag to ensure bits unions are inserted correctly.

Cast

This trait is implemented by types that a Value can be converted into by calling Value::cast. This includes types like String, Array, and u8.

Flag

Trait implemented by structs that can contain the flag of a bits union. Used in combination with Align and BitsUnion to ensure bits unions are inserted correctly.

Frame

Functionality shared by StaticFrame and DynamicFrame. These structs let you protect data from garbage collection. The lifetime of a frame is assigned to the values and outputs that are created using that frame. After a frame is dropped, these items are no longer protected and cannot be used.

IntoJulia

Trait implemented by types that can be converted to a Julia value in combination with Value::new. This trait can be derived for custom bits types that implement JuliaStruct.

JuliaStruct

This trait can be derived in order to provide a mapping between a type in Julia and one in Rust. When this trait is derived, the following traits are implemented:

JuliaType

Trait implemented by types that have an associated type in Julia.

JuliaTypecheck

This trait is used in combination with Value::is and DataType::is; types that implement this trait can be used to check many properties of a Julia DataType.

TemporarySymbol

Trait implemented by types that can be converted to a temporary Symbol.

ValidLayout

Trait implemented as part of JuliaStruct that is used to verify this type has the same layout as the Julia value.