Expand description
Official Rust SDK for the Rerout branded-link API.
Rerout is branded link infrastructure on Cloudflare. This crate wraps the HTTP API: create short links, render QR codes, read analytics, and verify webhook signatures.
Every public method is async and requires a Tokio
runtime. The client is built through a builder and is cheap to clone — the
inner reqwest::Client shares a connection pool.
§Quick start
use rerout::{CreateLinkInput, Rerout};
let rerout = Rerout::new("rrk_live_xxx")?;
let link = rerout
.links()
.create(&CreateLinkInput::new("https://example.com/q4-sale"))
.await?;
println!("Short URL: {}", link.short_url);§Namespaces
The Rerout client exposes four namespaces:
Rerout::links— create, list, get, update, delete, and per-link stats.Rerout::project— aggregate project stats and project metadata.Rerout::qr— a pure QR URL builder plus an authenticated SVG fetch.Rerout::webhooks— create, list, and delete webhook endpoints.
§Error handling
Every fallible call returns Result<T, ReroutError>. Match on the
ReroutError variant for branching, or read ReroutError::code for the
stable string identifier the API attaches to a failure.
§Webhook signatures
Incoming webhook deliveries are signed. Verify them with
webhooks::verify_rerout_signature, which performs a constant-time HMAC
comparison and rejects stale timestamps.
Re-exports§
pub use webhooks::DEFAULT_TOLERANCE_SECONDS;pub use webhooks::verify_rerout_signature;
Modules§
- webhooks
- Webhook signature verification — HMAC-SHA256 with constant-time compare.
Structs§
- ApiError
Details - Extra structured fields returned alongside an API error response.
- Client
Builder - Builder for
Rerout. - Create
Link Input - Body for
POST /v1/links. - Create
Webhook Input - Body for
POST /v1/projects/me/webhooks. - Created
Webhook - Result of creating a webhook endpoint.
- Daily
Clicks Point - One point in a daily clicks time series.
- Delete
Link Result - Response body for
DELETE /v1/links/:code. - Delete
Webhook Result - Response body for
DELETE /v1/projects/me/webhooks/:id. - Link
- A single short link as returned by the Rerout API.
- Link
Stats - Analytics for a single short link across the requested window.
- Links
- Link operations namespace. Reached via
Rerout::links. - List
Links Params - Query string for
GET /v1/links— small helper used bycrate::Links::list. - List
Links Result - A page of
Linkresults fromGET /v1/links. - List
Webhooks Result - Response body for
GET /v1/projects/me/webhooks. - Project
- Project-level namespace. Reached via
Rerout::project. - Project
Info - Response body for
GET /v1/projects/me. - Project
Stats - Aggregate analytics for a project across the requested window.
- Qr
- QR helpers. Reached via
Rerout::qr. - QrOptions
- QR rendering options. All fields are optional — omit to use server defaults.
- Rerout
- The Rerout API client.
- Stats
Breakdown - A single bucket in an analytics breakdown — one country, one device, etc.
- Tag
- A label attached to a
Link. Read-only — tag writes are ignored for API-key clients. - Update
Link Input - Body for
PATCH /v1/links/:code. - Webhook
- A webhook endpoint registered to the project. Mirrors the server-side
WebhookEndpointResponseshape. - Webhooks
- Webhook endpoint management namespace. Reached via
Rerout::webhooks.
Enums§
- QrEcc
- Error-correction levels for the QR endpoint.
- QrRefresh
- QR refresh / cache-bust token.
- Rerout
Error - Every error surfaced by the SDK.
- Webhook
Payload Format - Delivery payload encoding for a webhook endpoint.
Constants§
- DEFAULT_
BASE_ URL - Default production API base URL.
- DEFAULT_
TIMEOUT_ SECONDS - Default request timeout — 30 seconds.
Functions§
- build_
qr_ url - Build a QR URL from an arbitrary base URL. Used internally by
Qr::urland exposed as a free function for callers that already have a base URL in hand without constructing a full client.
Type Aliases§
- Result
- Convenience alias for
Result<T, ReroutError>.