Expand description
§Retrofit-rs
A type-safe, declarative HTTP client library for Rust, inspired by Java Retrofit.
§Features
- 🎯 Declarative API with procedural macros
- 🔒 Type-safe at compile time
- ⚡ Async/await support
- 🔄 Powerful interceptor system
- 📝 Automatic serialization/deserialization
§Quick Start (Async)
ⓘ
use retrofit_rs::{api, get, Result};
use serde::Deserialize;
#[derive(Deserialize)]
struct User {
name: String,
}
#[api("https://api.example.com")]
trait MyApi {
#[get("/users/{id}")]
async fn get_user(&self, id: u64) -> Result<User>;
}
#[tokio::main]
async fn main() -> Result<()> {
let api = MyApiClient::new()?;
let user = api.get_user(1).await?;
println!("{}", user.name);
Ok(())
}Re-exports§
pub use core::Body;pub use core::Header;pub use core::Path;pub use core::Query;pub use core::RequestBuilder;pub use core::Result;pub use core::RetrofitError;pub use async_client::Chain;pub use async_client::Interceptor;pub use async_client::Request;pub use async_client::Response;pub use async_client::Retrofit;pub use async_client::RetrofitBuilder;
Modules§
- async_
client - Async HTTP client implementation
- core
- Core module containing shared types and utilities