Skip to main content

hot_dev/
lib.rs

1//! Official Rust SDK for the [Hot Dev](https://hot.dev) API.
2//!
3//! The client is a thin mirror of the Hot API v1 resources. Request and
4//! response payloads use the Hot API wire format (`event_type`, `stream_id`,
5//! `event_data`, ...) as [`JsonObject`] values; the SDK never transforms
6//! user-owned payloads such as `event_data`. SDK-only options use
7//! Rust-idiomatic names (`base_url`, `timeout`).
8//!
9//! ```no_run
10//! use futures_util::StreamExt;
11//! use hot_dev::{HotClient, StreamEventExt, SubscribeWithEventOptions};
12//! use serde_json::json;
13//!
14//! # async fn demo() -> hot_dev::Result<()> {
15//! let client = HotClient::builder(std::env::var("HOT_API_KEY").unwrap()).build();
16//!
17//! // base_url defaults to https://api.hot.dev. For local development with
18//! // `hot dev`, use .base_url("http://localhost:4681").
19//!
20//! let mut events = client.streams().subscribe_with_event(
21//!     json!({
22//!         "event_type": "team-agent:ask",
23//!         "event_data": { "question": "what is blocking launch?" },
24//!     }),
25//!     SubscribeWithEventOptions::default(),
26//! );
27//! while let Some(event) = events.next().await {
28//!     let event = event?;
29//!     if event.event_type() == "run:stop" {
30//!         println!("{:?}", event.run());
31//!         break;
32//!     }
33//! }
34//! # Ok(())
35//! # }
36//! ```
37//!
38//! Authenticated clients should run server-side; browser or untrusted clients
39//! should call your own backend instead of embedding a Hot API key.
40
41mod client;
42mod error;
43mod resources;
44mod sse;
45mod streaming;
46mod transport;
47
48pub use client::{HotClient, HotClientBuilder};
49pub use error::{ApiError, Error};
50pub use resources::{
51    BuildUpload, BuildsResource, CallOptions, ContextResource, DomainsResource, EnvResource,
52    EventsResource, FilesResource, OrgResource, ProjectsResource, RunsResource,
53    ServiceKeysResource, SessionsResource, StreamsResource, SubscribeWithEventOptions, WaitOptions,
54};
55pub use streaming::{EventStream, StreamEventExt};
56
57/// A JSON object in the Hot API wire format.
58pub type JsonObject = serde_json::Map<String, serde_json::Value>;
59
60/// One event from a Hot run stream (`type`, `data_type`, `payload`, `run`, ...).
61pub type StreamEvent = JsonObject;
62
63/// Result alias for SDK operations.
64pub type Result<T> = std::result::Result<T, Error>;