Crate zenwave

Crate zenwave 

Source
Expand description

§Ergonomic HTTP client framework

Zenwave is an ergonomic HTTP client framework. It has a lot of features:

  • Follow redirect
  • Cookie store
  • Bearer and Basic authentication
  • Powerful middleware system (Add features you need!)
  • Streaming body transfer
  • Cross-platform websocket client (optional ws feature, enabled by default)

§Quick start

use zenwave::get;
let response = get("https://example.com/").await?;
let text = response.into_body().into_string().await?;
println!("{text}");

§Backend Selection

§WASM (wasm32)

On WebAssembly targets, Zenwave automatically uses the built-in web backend powered by the browser’s Fetch API. No configuration is needed or available. Note: Explicitly selecting a backend on wasm32 will result in a compile error.

§Native Platforms

On native platforms, Zenwave supports multiple HTTP client backends.

§Default Backend (default-backend feature)

The default configuration uses platform-specific TLS selection:

  • Apple platforms (macOS/iOS): hyper + native-tls (Security.framework)
  • Other platforms: hyper + rustls with system certificates

§Explicit Backend Selection

Available backends (enable via Cargo features):

  • hyper-rustls: Hyper with rustls TLS (uses system certificates).
  • hyper-native-tls: Hyper with native TLS (OpenSSL, SChannel, or Security.framework).
  • curl-backend: libcurl-based backend with proxy support.
  • apple-backend: Apple’s native NSURLSession (macOS/iOS only).

To use a different backend, disable default features and enable your choice:

# Use curl backend instead
zenwave = { version = "*", default-features = false, features = ["curl-backend"] }

# Use hyper with native-tls explicitly
zenwave = { version = "*", default-features = false, features = ["hyper-native-tls"] }

# Use hyper with rustls explicitly
zenwave = { version = "*", default-features = false, features = ["hyper-rustls"] }

Re-exports§

pub use cache::Cache;
pub use oauth2::OAuth2ClientCredentials;
pub use error::Error;
pub use timeout::Timeout;

Modules§

auth
Authentication middlewares for HTTP requests.
backend
Platform-specific HTTP client backends.
cache
HTTP caching middleware that honors basic Cache-Control and validator headers.
cookie
Middleware for managing cookies in HTTP requests and responses.
endpoint
HTTP endpoint abstraction for request handling.
error
Unified error types for zenwave HTTP client.
header
HTTP header types
method
The HTTP request method
middleware
Middleware functionality for HTTP request and response processing.
multipart
Multipart/form-data utilities.
oauth2
OAuth2 helpers and middleware.
redirect
Middleware for following HTTP redirects.
retry
Middleware for retrying failed HTTP requests.
sse
Server-Sent Events (SSE) implementation module.
timeout
Timeout middleware backed by a runtime-agnostic timer.
uri
URI component of request and response lines
utils
Utility types and functions for HTTP operations.
version
HTTP version
websocket
Websocket utilities (requires the ws feature).
ws
WebSocket message and configuration types.

Macros§

http_error
Defines a zero-sized [HttpError] type that renders as a static message.
http_error_fmt
Defines a zero-sized type that implements [HttpError] with a custom formatter.

Structs§

Body
Flexible HTTP body that can represent data in various forms.
Extensions
A type map of protocol extensions.
Method
The Request Method (VERB)
StatusCode
An HTTP status code (status-code in RFC 9110 et al.).
Uri
The URI component of a request.
Version
Represents a version of the HTTP spec.

Enums§

BodyError
Error type for body operations.

Traits§

Client
Trait representing an HTTP client with middleware support.
Endpoint
A trait for types that can handle HTTP requests and generate responses.
HttpError
Trait for errors that have an associated HTTP status code.
Middleware
Trait for implementing middleware that can process HTTP requests and responses.
ResponseExt
Extension trait for Response to add additional functionality.
ResultExt
Extension trait for adding status codes to Results.

Functions§

client
Create a default HTTP client backend.
delete
Send a DELETE request to the specified URI using the default client backend.
get
Create a default HTTP client backend. Send a GET request to the specified URI using the default client backend.
post
Send a POST request to the specified URI using the default client backend.
put
Send a PUT request to the specified URI using the default client backend.

Type Aliases§

BoxHttpError
A boxed HTTP error trait object.
Request
A type alias for HTTP requests with a custom Body type.
Response
A type alias for HTTP responses with a custom Body type.
Result
A specialized Result type for HTTP operations.