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 six namespaces:

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

AbVariant
A weighted Smart-Links A/B testing destination as returned by the API.
ApiErrorDetails
Extra structured fields returned alongside an API error response.
BatchCreateLinksResult
Response body for POST /v1/links/batch.
BatchLinkInput
One entry in a crate::Links::create_batch request.
BatchLinkResult
Per-item outcome of a crate::Links::create_batch request.
ClientBuilder
Builder for Rerout.
ConversionResult
Response body for POST /v1/conversions.
Conversions
Conversion-tracking namespace. Reached via Rerout::conversions.
CreateAbVariantInput
A weighted A/B variant on CreateLinkInput / UpdateLinkInput.
CreateLinkInput
Body for POST /v1/links.
CreateTagInput
Body for POST /v1/projects/me/tags.
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.
DeleteTagResult
Response body for DELETE /v1/projects/me/tags/:tag_id.
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.
ListTagsResult
Response body for GET /v1/projects/me/tags.
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.
RecordConversionInput
Body for POST /v1/conversions.
Rerout
The Rerout API client.
RoutingRule
A Smart-Links conditional redirect rule.
StatsBreakdown
A single bucket in an analytics breakdown — one country, one device, etc.
Tag
A label attached to a Link. Returned by tag writes (crate::Tags::create / crate::Tags::update) and embedded in a Link’s tags.
TagSummary
A Tag plus its live link count — the shape returned by crate::Tags::list.
Tags
Tag management namespace. Reached via Rerout::tags.
UpdateLinkInput
Body for PATCH /v1/links/:code.
UpdateTagInput
Body for PATCH /v1/projects/me/tags/:tag_id.
Webhook
A webhook endpoint registered to the project. Mirrors the server-side WebhookEndpointResponse shape.
Webhooks
Webhook endpoint management namespace. Reached via Rerout::webhooks.

Enums§

Environment
Rerout data plane selected by the client.
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.
SANDBOX_BASE_URL
Base URL for the isolated Rerout sandbox.

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>.