Menu

A Claude Client in One Rust File, and the First Dependency
📰

A Claude Client in One Rust File, and the First Dependency

DEV Community: rust·stepinto.dev·4 days ago
#QTSVZ1k3
#devtorust#devto#dev#index#rust
Reading 0:00
15s threshold

Bash, C# and Go all had HTTP and TLS in their standard libraries, but unfortunately Rust doesn't. The spec lets a language without them use one named library for the transport, and that library counts towards size, so this is the first time the leaderboard has to price a dependency. The transport is ureq with rustls, the parsing is serde_json , and together they bring in thirty-six crates. The result is still the smallest thing on the board so far.

The code is at github.com/AndyCross/claude-hot-path , and the leaderboard is at /claude-hot-path/ .

Choosing the transport

The usual answer for HTTP in Rust is reqwest , which is async and brings tokio and hyper with it. For a client that makes two sequential requests and streams the reply to stdout, async buys nothing and costs a runtime. ureq is the blocking alternative, it defaults to rustls so there is no OpenSSL to link, and version 3 exposes the response body as a Read , which is all the SSE loop needs.

One configuration line matters.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.