Jacquard
A suite of Rust crates intended to make it much easier to get started with atproto development, without sacrificing flexibility or performance.
Jacquard is simpler because it is designed in a way which makes things simple that almost every other atproto library seems to make difficult.
It is also designed around zero-copy/borrowed deserialization: types like Post<'_> can borrow data (via the CowStr<'_> type and a host of other types built on top of it) directly from the response buffer instead of allocating owned copies. Owned versions are themselves mostly inlined or reference-counted pointers and are therefore still quite efficient. The IntoStatic trait (which is derivable) makes it easy to get an owned version and avoid worrying about lifetimes.
0.6.0 Release Highlights:
- WebSocket streaming (gated behind feature: "streaming" in
jacquardand "websocket" injacquard-common) - Base level HTTP streamed responses and (on non-wasm platforms) request support (gated behind feature: "streaming" in
jacquard-common) - Support for atproto event stream endpoints (e.g. subscribeRepos, subscribeLabels, firehose)
- Jetstream subscriber support and implementation
- zstd compression support for JSON websocket endpoints
- XRPC streaming procedure traits for endpoints with large payloads, experimental manual implementations in
jacquard - Fixed blob upload and download bugs, CID link deserialization issues.
WARNING
A lot of the streaming code is still pretty experimental. The examples work, though.
The modules are also less well-documented, and don't have code examples. There are also a lot of utility functions for conveniently working with the streams and transforming them which are lacking. Use n0-future to work with them, that is what Jacquard uses internally as much as possible.
Changelog
[./CHANGELOG.md]
Goals and Features
- Validated, spec-compliant, easy to work with, and performant baseline types
- Batteries-included, but easily replaceable batteries.
- Easy to extend with custom lexicons using code generation or handwritten api types
- Straightforward OAuth
- Stateless options (or options where you handle the state) for rolling your own
- All the building blocks of the convenient abstractions are available
- Server-side convenience features
- Lexicon Data value type for working with unknown atproto data (dag-cbor or json)
- An order of magnitude less boilerplate than some existing crates
- Use as much or as little from the crates as you need
Example
Dead simple API client. Logs in with OAuth and prints the latest 5 posts from your timeline.
// Note: this requires the `loopback` feature enabled (it is currently by default)
use Parser;
use CowStr;
use GetTimeline;
use ;
use OAuthClient;
use LoopbackConfig;
use XrpcClient;
use IntoDiagnostic;
async
If you have just installed, you can run the examples using just example {example-name} {ARGS} or just examples to see what's available.
Component crates
Jacquard is broken up into several crates for modularity. The correct one to use is generally jacquard itself, as it re-exports most of the others.
Development
This repo uses Flakes
# Dev shell
# or run via cargo
# build
There's also a justfile for Makefile-esque commands to be run inside of the devShell, and you can generally cargo ... or just ... whatever just fine if you don't want to use Nix and have the prerequisites installed.