ATrium API: Rust library for Bluesky's atproto services

ATrium API is a Rust library that includes the definitions of XRPC requests and their associated input/output model types. These codes are generated from the Lexicon schema on atproto.com.

Usage

You can use any HTTP client that implements atrium_api::xrpc::HttpClient to make use of the XRPC requests. Below is the simplest example using reqwest.

```rust

[derive(Default)]

struct MyClient(reqwest::Client);

[asynctrait::asynctrait]

impl atriumapi::xrpc::HttpClient for MyClient { async fn send( &self, req: http::Request>, ) -> Resulthttp::Response>, Box> { let res = self.0.execute(req.tryinto()?).await?; let mut builder = http::Response::builder().status(res.status()); for (k, v) in res.headers() { builder = builder.header(k, v); } builder .body(res.bytes().await?.tovec()) .maperr(Into::into) } }

[asynctrait::asynctrait]

impl atrium_api::xrpc::XrpcClient for MyClient { fn host(&self) -> &str { "https://bsky.social" } fn auth(&self) -> Option<&str> { None } }

atriumapi::impltraits!(MyClient);

[tokio::main]

async fn main() -> Result<(), Box> { use atriumapi::com::atproto::server::createsession::{CreateSession, Input}; let session = MyClient::default() .create_session(Input { identifier: ".bsky.social".into(), password: "".into(), }) .await?; println!("{:?}", session); Ok(()) } ```