Compiling to Rust
TreeLDR can generate a Rust type definition for each defined layout. For instance, consider the following layout for the schema:BlogPosting
type:
TreeLDR can generate the following Rust type:
Non required
properties are automatically translated into fields with an Option
type.
Embedding
The list of all the TreeLDR files we need to import, given as parameters of the
tldr
attribute; andThe destination (path in the module) of each type definition. This is done by declaring a submodule for each IRI prefix of interest. The type definition of each layout will be generated in the submodule whose prefix matches the identifier of the layout.
This will expand into the following code:
Traits Implementations
In addition to the type definitions, TreeLDR will also provide some traits implementations for those types.
Core Traits
Each type will implement Clone
, PartialEq
, Eq
, PartialOrd
, Ord
and Hash
.
FromRdf
IntoJsonLd
Last updated
Was this helpful?