Official, generated-first Rust client for ArchAstro: typed HTTP resources, automatic single-flight token refresh, SSE streams, and Phoenix channels.
[dependencies]
archastro = "0.1"use archastro::Client;
#[tokio::main]
async fn main() -> archastro::Result<()> {
let client = Client::builder()
.secret_key(std::env::var("ARCHASTRO_SECRET_KEY").unwrap())
.build()?;
let status = client.v1().status().ping().await?;
println!("{status:?}");
Ok(())
}- Async API: every generated HTTP call is
asyncand uses a cloneable, pooledreqwest::Client. - Blocking API: default
blockingfeature adds a_blockingvariant to non-streaming methods. Do not call it from inside a Tokio runtime. - SSE: streaming endpoints return
SseStream<EventEnum>, implementingfutures_core::Streamwith reconnection and last-event-ID support. - Channels:
client.socket().await?.connect().await?opens a Phoenix v2 socket; generated facades provide typed join responses, messages, and push streams. The runtime reconnects, rejoins, verifies heartbeats, and buffers pushes while a desired channel is reconnecting. - Auth: secret keys, publishable keys, bearer/system tokens, and
Client::with_credentialsare supported. Concurrent 401s share one generation-fenced refresh because refresh tokens are single-use. - App sessions: configure a
SessionStore, then userestore_session,install_app_session, andsign_out. Refresh-token rotations are written back after the in-memory bearer is updated.
npm ci
./scripts/regenerate_sdk.sh --local ../archastro-openapi
cargo fmt --all -- --check
cargo clippy --all-features --all-targets -- -D warnings
cargo test --all-features
cargo test --all-features --test generated_rest_contract -- --ignored --test-threads=1
cargo test --all-features --test generated_stream_contract -- --ignored --test-threads=1
cargo test --all-features --test generated_channel_contract -- --ignored --test-threads=1
cargo test --all-features --test sse_runtime_contract -- --ignored --test-threads=1
cargo test --all-features --test channel_runtime_contract -- --ignored --test-threads=1Generated files carry a content hash and must only be changed through
@archastro/sdk-generator.