Skip to main content

Crate runlimit_core

Crate runlimit_core 

Source
Expand description

Framework-neutral contracts shared by Runlimit storage backends.

This crate defines anchored fixed-window and GCRA policies, opaque subject keys, checks, and backend-independent decisions. It deliberately contains no async runtime, transport framework, or persistence integration.

Applications own subject normalization and policy selection. Raw subjects should be converted to SubjectKey values with KeyHasher before they cross into a storage backend. Async application adapters can use Limiter for generic dispatch across storage backends without requiring boxed futures.

The optional serde feature provides validated policy and response-metadata wire types. Opaque SubjectKey, CounterKey, and PolicyFingerprint values intentionally remain non-serializable.

Structs§

AdmissionObservation
Metadata for one completed admission operation.
CapacityObservation
Local capacity use reported by a bounded backend.
Check
One proposed quota charge against a policy and opaque subject.
CleanupObservation
Metadata for one bounded cleanup pass.
CounterKey
The complete logical identity of one stored rate-limit counter.
Decision
The outcome of evaluating one check.
FixedWindowPolicy
An anchored fixed-window rate-limit policy.
GcraPolicy
A generic-cell-rate-algorithm policy.
KeyHasher
Derives opaque subject keys using HMAC-SHA-256.
PolicyFingerprint
A deterministic digest of a policy’s identity, scope, and configuration.
PolicyId
A stable application-defined rate-limit policy identifier.
ScopeId
A stable application-defined scope within a rate-limit policy.
SubjectKey
An opaque, fixed-width subject identifier used by storage backends.

Enums§

AdmissionOperation
Whether an admission evaluated one check or an atomic batch.
AdmissionOutcome
Classification of a completed admission operation.
BatchDecision
The atomic outcome of evaluating checks in caller-supplied order.
BatchError
A backend-independent invalid atomic batch.
CheckError
An invalid check cost.
ConsumptionStatus
What a caller can know about quota consumption after an operation.
Denial
Structured details for a denied check.
GcraPolicyError
An invalid GCRA policy configuration.
IdentifierError
An invalid policy or scope identifier.
KeyHasherError
An invalid subject-key hasher configuration.
Observation
A backend-neutral operational observation.
PolicyError
An invalid fixed-window policy configuration.
QuotaMode
Whether quota exhaustion is enforced or reported in shadow mode.

Constants§

MAX_IDENTIFIER_LENGTH
Maximum encoded length of a policy or scope identifier.
MAX_LIMIT
Largest quota or immediate capacity supported by built-in policies.
MAX_WINDOW
Largest policy duration supported by built-in policies.
MAX_WINDOW_MILLIS
Largest whole-millisecond policy duration supported by built-in policies.

Traits§

Limiter
An asynchronous, backend-independent rate limiter.
Observer
Receives synchronous, backend-neutral operational observations.
RateLimitPolicy
Backend-independent policy metadata required to construct a check.

Functions§

validate_batch
Validates backend-independent structural requirements for an atomic batch.