Getting Started

Installation

How to add Trypema to your Rust project, including feature flags for Redis and async runtime support.

Add Trypema to your project

Local only (no Redis)

If you only need in-process rate limiting with no external dependencies:

[dependencies]
trypema = "0.1"

This gives you access to the local provider with both the absolute and suppressed strategies. No Redis dependency is compiled in.

Redis + Hybrid providers (Tokio)

To enable distributed rate limiting via Redis and the hybrid provider, add the redis-tokio feature flag along with the redis and tokio crates:

[dependencies]
trypema = { version = "0.1", features = ["redis-tokio"] }
redis = { version = "1", features = ["aio", "tokio-comp", "connection-manager"] }
tokio = { version = "1", features = ["full"] }

This enables all three providers: local, Redis, and hybrid.

Redis + Hybrid providers (Smol)

If you are using the Smol async runtime instead of Tokio:

[dependencies]
trypema = { version = "0.1", features = ["redis-smol"] }
redis = { version = "1",  features = ["aio", "smol-comp", "connection-manager"] }
smol = "2"

Feature flags

FeatureWhat it enables
(default)Local provider only. No Redis dependency.
redis-tokioRedis + Hybrid providers with the Tokio async runtime.
redis-smolRedis + Hybrid providers with the Smol async runtime.
redis-tokio and redis-smol are mutually exclusive. Enabling both produces a compile error.

Requirements

RequirementMinimum version
RustEdition 2024
Redis (if using Redis/Hybrid)7.2+
Tokio (if using redis-tokio)1.x
Smol (if using redis-smol)2.x

Verify installation

After adding the dependency, run:

cargo check

If you are using Redis features, make sure you have a Redis server running for integration tests:

REDIS_URL=redis://127.0.0.1:6379/ cargo test --features redis-tokio

Next steps