Skip to main content

Crate rerout

Crate rerout 

Source
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§

ApiErrorDetails
Extra structured fields returned alongside an API error response.
ClientBuilder
Builder for Rerout.
CreateLinkInput
Body for POST /v1/links.
CreateWebhookInput
Body for POST /v1/projects/me/webhooks.
CreatedWebhook
Result of creating a webhook endpoint.
DailyClicksPoint
One point in a daily clicks time series.
DeleteLinkResult
Response body for DELETE /v1/links/:code.
DeleteWebhookResult
Response body for DELETE /v1/projects/me/webhooks/:id.
Link
A single short link as returned by the Rerout API.
LinkStats
Analytics for a single short link across the requested window.
Links
Link operations namespace. Reached via Rerout::links.
ListLinksParams
Query string for GET /v1/links — small helper used by crate::Links::list.
ListLinksResult
A page of Link results from GET /v1/links.
ListWebhooksResult
Response body for GET /v1/projects/me/webhooks.
Project
Project-level namespace. Reached via Rerout::project.
ProjectInfo
Response body for GET /v1/projects/me.
ProjectStats
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.
StatsBreakdown
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.
UpdateLinkInput
Body for PATCH /v1/links/:code.
Webhook
A webhook endpoint registered to the project. Mirrors the server-side WebhookEndpointResponse shape.
Webhooks
Webhook endpoint management namespace. Reached via Rerout::webhooks.

Enums§

QrEcc
Error-correction levels for the QR endpoint.
QrRefresh
QR refresh / cache-bust token.
ReroutError
Every error surfaced by the SDK.
WebhookPayloadFormat
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::url and 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>.