A better Rust ATProto crate

Build lexicon json #21

closed
opened by netology.tngl.sh

If I need to build custom lexicon for a custom app, do I have to manually write the lexicon Json file to generate rust code using jacquard_lexgen

that's the most-supported path right now. I would suggest potentially using one of the existing tools for authoring lexicons, such as https://typelex.org/. the atcute lex-cli also has some options there https://tangled.org/mary.my.id/atcute/blob/f985cbbc938eb9fa9f1a12ccb2ea6901953727ae/packages/lexicons/lex-cli/CHANGELOG.md#250 now (though that's more typescript->lexicon json).

Jacquard does have a similar capability, though it's not well-documented. You can #[derive(LexiconSchema)] on rust types and that will make available at runtime a lexicon schema. There's some stuff that's a bit picky, I recommend reading through the test code to see how to derive a fairly complete set of lexicons. And then, in the jacquard-lexgen crate there's an extract_schemas binary. That will go through the workspace you run it in and look for any rust code that derives LexiconSchema, then build the schema document for the struct and export it as JSON.

sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 2
AT URI
at://did:plc:b4sujryiw6ffhpnqyz2kgjnt/sh.tangled.repo.issue/3m6ez7cxytv22