I have a Rust project and I want to compile a Typst file from Rust. There’s no convenient way to use the Rust Typst library.
I could call the Typst CLI binary through the command line, but that requires the user of the crate to also have Typst. It would be much better if it could be a dependency. It’s also just not very convenient.
There is Typst As Lib which is what I’m ideally looking for but it isn’t official and it’s also unstable.
The official Rust library is basically a toolkit that gives maximum flexibility so that many different things, including the web app and CLI compiler, can be implemented on top of it. A more high-level library is currently not planned—one reason being that the team would have to come up with a stable high-level API.
In other words: Typst as Lib is exactly what you’re looking for right now. You won’t find something more stable, and it saves you some initial work. If it should turn out to not satisfy your needs you can still fork it/copy the relevant code directly to your project (respecting the MIT license, of course) and it’s as if you had used the official low-level library, just with a bit less work.
1 Like