runlimit_core/lib.rs
1//! Framework-neutral contracts shared by Runlimit storage backends.
2//!
3//! This crate defines anchored fixed-window and GCRA policies, opaque subject
4//! keys, checks, and backend-independent decisions. It deliberately contains
5//! no async runtime, transport framework, or persistence integration.
6//!
7//! Applications own subject normalization and policy selection. Raw subjects
8//! should be converted to [`SubjectKey`] values with [`KeyHasher`] before they
9//! cross into a storage backend.
10//! Async application adapters can use [`Limiter`] for generic dispatch across
11//! storage backends without requiring boxed futures.
12//!
13//! The optional `serde` feature provides validated policy and response-metadata
14//! wire types. Opaque [`SubjectKey`], [`CounterKey`], and
15//! [`PolicyFingerprint`] values intentionally remain non-serializable.
16
17mod batch;
18mod check;
19mod counter;
20mod decision;
21mod identifier;
22mod key;
23mod limiter;
24mod observation;
25mod policy;
26
27pub use batch::{BatchError, validate_batch};
28pub use check::{Check, CheckError};
29pub use counter::CounterKey;
30pub use decision::{BatchDecision, Decision, Denial};
31pub use identifier::{IdentifierError, MAX_IDENTIFIER_LENGTH, PolicyId, ScopeId};
32pub use key::{KeyHasher, KeyHasherError, SubjectKey};
33pub use limiter::Limiter;
34pub use observation::{
35 AdmissionObservation, AdmissionOperation, AdmissionOutcome, CapacityObservation,
36 CleanupObservation, ConsumptionStatus, Observation, Observer, observe_safely,
37};
38pub use policy::{
39 FixedWindowPolicy, GcraPolicy, GcraPolicyError, MAX_LIMIT, MAX_WINDOW, MAX_WINDOW_MILLIS,
40 PolicyError, PolicyFingerprint, QuotaMode, RateLimitPolicy,
41};