Skip to content

ilaborie/pincer

Repository files navigation

pincer

Declarative HTTP client for Rust.

CI Crates.io docs.rs Downloads MSRV License

Proof of Concept: This project is experimental and intended for learning and exploration. It is not recommended for production use.

AI-Assisted Development: This project was built with assistance from Claude (Anthropic). Code, documentation, and tests were developed collaboratively between human and AI.

Quick Start

[dependencies]
pincer = "0.1"
serde = { version = "1.0", features = ["derive"] }
tokio = { version = "1", features = ["full"] }
use pincer::prelude::*;

#[derive(Debug, Deserialize)]
pub struct User {
    pub id: u64,
    pub name: String,
}

#[pincer(url = "https://api.example.com")]
pub trait UserApi {
    #[get("/users/{id}")]
    async fn get_user(&self, #[path] id: u64) -> pincer::Result<User>;
}

#[tokio::main]
async fn main() -> pincer::Result<()> {
    let client = UserApiClientBuilder::default().build()?;
    let user = client.get_user(42).await?;
    Ok(())
}

Features

  • Declarative: Define HTTP clients with proc-macro attributes
  • Type-safe: Compile-time checked path, query, and body parameters
  • Async: Built on tokio and hyper
  • Middleware: Tower ecosystem integration (retry, auth, logging)
  • TLS: Secure connections via rustls

Learn More

Inspiration

Inspired by OpenFeign, the Java declarative HTTP client.

Key differences from OpenFeign:

  • Rust's async/await instead of blocking calls
  • Compile-time macro expansion instead of runtime proxies
  • Tower middleware instead of interceptors
  • Type-safe parameters enforced by the compiler

Minimum Supported Rust Version

Rust 1.92 or later.

License

MIT OR Apache-2.0

About

PoC for a Rust HTTP client based on reqwest + some macros

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE-APACHE
MIT
LICENSE-MIT

Contributing

Stars

Watchers

Forks

Packages

No packages published