/es'kema/
layout , scheme
Warning
This project is a work in progress and in the early stages of development. Many items may not work or even been implemented yet
Rust tools for interacting with custom ATProto Lexicons. This is a direct fork of atrium-codegen, any code generation and parsing of the JSON Lexicon records are thanks to that project and their efforts.
You should be able to easily use strong Rust types from ATProto lexicon schemas to build out your Rust project that uses ATProto records.
You should be able to validate those records structure and content against that schema. If your app depends on a field being there or being a certain length you should be able to easily check that with out manually doing it.
- Generate Rust types from JSON Lexicon files and be able to use them in atrium's
com.atproto.repo.*
's record methods easily via CLI - Generate Rust types the same way but in a
build.rs
- Generate Rust types from a passed in LexiconDoc
- Generate Rust types from remote did lexicon schema ATProto records
- Custom Lexicon validation of data
- Helpers for writing valid DNS TXT records and ATProto records so your Lexicons are public and valid
- A way to write Rust types with being descriptive to generate Lexicon files
I've been playing around with ATProto records after checking out the Statusphere example app, I'd like to recreate this tutorial in Rust and have a way to generate the Lexicon records in a type-safe way. Along the way I had a lot of issues with validating and in general creating custom records. So I am hoping this project will help others with an easier API to validate ATProto records and create them when using rust
Some problems these crates will try to solve
- Rust code generation from lexicon files for Rust types
- Serializing and deserializing those Rust ATProto record types easily for use in atrium
- It does not appear Bluesky currently support custom lexicon scheme resolution and validation so to give you the tools in Rust to know if the record is valid according to the schema.
Currently, esquema-cli and esquema-codegen are not on crates.io. The plan is once milestone 1. Code Generation is completed to publish. Till then if you want to get in on the fun, can use the following.
cargo install esquema-cli --locked --git https://github.com/fatfingers23/esquema.git
# You can keep it in your build-dependecies
[build-dependencies]
esquema-codegen = { git = "https://github.com/fatfingers23/esquema.git", branch = "main" }
For usage check the esquema-cli section or the esquema-cli project
A command line tool to help you generate Rust types from lexicon definitions, Check esquema-example for an example on how to run the command in a projects setting.
Some examples:
create types from local lexicon schema JSON files
esquema-cli generate local --lexdir ./esquema-example/lexicons/ --outdir ./esquema-example/src/ --modules lexicons
Create types from a remote ATProtocol record with a lexicon schema. Using statusphere as the example
esquema-cli generate remote --handle statusphere.xyz --namespace xyz --outdir ./esquema-example/src/ --modules lexicons
A fork of atrium-codegen to generate the Rust types in a way that can be used by other projects like how in atrium-api is used for Bluesky's lexicons.
An example project show casing how to use esquema to generate Rust types from ATProto lexicon records via esquema-cli or using esquema-codegen to generate the types from a build.rs file.
Check out the readme for more info.
Future. This will be a crate to help you validate custom lexicon schemas to make sure the record is valid according to the lexicon schema