Expand description
Typed, fluent HTTP client.
This module provides a builder-oriented API for issuing HTTP requests
against a configurable Target — a localhost port or an arbitrary
remote base URL — and deserialising the response body into a concrete Rust
type via serde.
The entry point is Client. Call any method constructor
(get, post, etc.) to obtain a
RequestBuilder. Optionally attach a JSON body via
json or URL query parameters via
query, then finalise with
send (async) or
send_sync (blocking).
All seven standard HTTP methods are supported.
§Builder chains at a glance
| Chain | Sends |
|---|---|
client.method(endpoint).send().await | plain request |
.json(value).send().await | Content-Type: application/json body |
.query(params).send().await | serialised query string |
§Example
use toolkit_zero::socket::client::{Client, Target};
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Serialize)] struct Item { id: u32, name: String }
#[derive(Serialize)] struct NewItem { name: String }
#[derive(Serialize)] struct Filter { page: u32 }
let client = Client::new(Target::Localhost(8080));
// Plain async GET
let items: Vec<Item> = client.get("/items").send().await?;
// POST with a JSON body
let created: Item = client
.post("/items")
.json(NewItem { name: "widget".into() })
.send()
.await?;
// GET with query parameters
let page: Vec<Item> = client
.get("/items")
.query(Filter { page: 2 })
.send()
.await?;
// Synchronous DELETE
let _: Item = client.delete("/items/1").send_sync()?;Structs§
- Client
- HTTP client for making typed requests against a
Targetserver. - Encrypted
Body Request Builder - A request builder that VEIL-seals the body before sending.
- Encrypted
Query Request Builder - A request builder that VEIL-seals query params and sends them as
?data=<base64url>. - Json
Request Builder - A request builder that will send a JSON-serialised body.
- Query
Request Builder - A request builder that will append serialisable query parameters to the URL.
- Request
Builder - A request builder with no body or query parameters attached.
Enums§
- Client
Error - Error returned by
EncryptedBodyRequestBuilderandEncryptedQueryRequestBuilder. - Target
- The target server for a
Client.
Attribute Macros§
- request
- Concise HTTP client request for
toolkit-zerosocket-client routes.