Async Code Generator
A library for async code generation that imposes no ownership choices (can use borrowed or owned data) and is fully composable using generics and general-purpose structs.
Example
This may seem tedious, but the design allows for maximum re-usability and composability.
async
Will render as:
Design
The API is conceptually simple. Performing code generation is akin to writing a syntax tree.
Model
Writable elements are composed from other writable elements. They are divided into two kinds:
Writable- the main trait used by the libraryWritableSeq- for a sequence of writable values handled in the same way.
An example of a writable sequence would be function arguments, type variables, etc. An example of a standalone writable value would be a function body.
Your Data
This library is made for industrial-strength, low-allocation code generation. As a result, it's intended that callers create their own writable types from their own data.
For example, let's say you want to generate a big enum. Well, you would implement your own WritableSeq to fill out the enum elements.
Async and Errors
Every code generation-related function returns the library user's error type.
Also, the methods are async and must be awaited as such. This lets the library user plug in their favorite async runtime... because why not make code generation fast?
Library
Code Standards
Except for the utils module, the library is free of panics and unsafe code. That being said, we hold ourselves to high standards:
- Panics are clearly documented.
- Unsafe code is clearly explained through comments, and run through MIRI and testing.
Dependency
Add this library to your Cargo.toml. Check crates.io for the latest version.
[]
= "0.6.0"
Licensing
Licensed under the Apache License v2.0. See the LICENSE.txt.