Languages
Rust
The Rust SDK publishes to crates.io.
Install
bash
cargo add your-org-api-clientOr in Cargo.toml:
toml
[dependencies]
your-org-api-client = "1.0"Options
| Option | Values | Default |
|---|---|---|
| Client style | functions, namespaced, class, class-namespaced | functions |
| Argument style | object, positional | object |
| Namespace | tags, path | tags |
| Doc comments | full, minimal | full |
| File header | omit, include | omit |
| Usage example | full, concise | full |
Keep Doc comments on full
Doc comments set to full becomes rustdoc, which is what your users read on docs.rs. Rust consumers expect that page to be complete, and minimal leaves it bare.
Package name
Crate names are global, flat, and first-come-first-served. There are no scopes, so the good short names went years ago:
text
acme-apicrates.io is permanent and unscoped
A crate name cannot be transferred away from you, reused, or renamed, and a published version can be yanked but never replaced. With no namespace to hide behind, pick a name you can live with. See Publishing.
What callers write
rust
use acme::Client;
#[tokio::main]
async fn main() -> Result<(), acme::Error> {
let client = Client::new(std::env::var("ACME_TOKEN")?);
let mut users = client.users().list(100);
while let Some(user) = users.next().await? {
println!("{}", user.id);
}
Ok(())
}Errors come back as a typed Result, so a caller who ignores a failure gets a compiler warning rather than a silent bug.