News for hackers. Stuff that matters.
Re:Automatically generating types for Cloudflare Workers by trevyn on Tuesday November 16, 2021 @07:03PM (#29247882)
For those who don’t know, much of Serde’s magic is powered by Rust procedural derive macros, which generate (i.e. “derive”) code from a Rust struct definition.

You can, of course, write your own derive macros, and apply several derive macros to a single struct.

I wrote some to derive SQLite schemas and migrations and queries and auto-generate frontend TypeScript RPC code. So my source of truth is the Rust struct, and that sort of magically generates everything else.

I don’t know if this is a good idea, but it’s been pretty fun so far. :-)

There are also derive-macro-powered crates to do GraphQL, other flavors of SQL, WASM bindings, etc etc.

There are no comments on this comment yet.