pub struct Native { /* private fields */ }Expand description
The native runtime. Adapters are passed in as instances (the same
pattern as the Cloudflare runtime’s .mailer(..)/.captcha(..)):
a Postgres or SQLite Database from the
matching adapter crate, a RedisRateLimiter
and RedisKv over a shared Redis connection
manager, Resend/Turnstile unchanged from the Workers path.
Config — including HARNESS_SECRET for the Signer port — is read
from std::env through the same cratefield_core::Config trait
(EnvConfig), so module keys behave identically on both runtimes.
Implementations§
Source§impl Native
impl Native
pub fn new() -> Self
Sourcepub fn db(self, db: impl Database + 'static) -> Self
pub fn db(self, db: impl Database + 'static) -> Self
The Database port: Postgres (cratefield-adapter-postgres) or
SqliteDatabase (cratefield-adapter-sqlite) — any Database
implementation.
Sourcepub fn rate_limiter(self, limiter: impl RateLimiter + 'static) -> Self
pub fn rate_limiter(self, limiter: impl RateLimiter + 'static) -> Self
The RateLimiter port: RedisRateLimiter in this crate, or a
test fake.
Sourcepub fn rate_limiter_arc(self, limiter: Arc<dyn RateLimiter>) -> Self
pub fn rate_limiter_arc(self, limiter: Arc<dyn RateLimiter>) -> Self
rate_limiter for an already-shared limiter.
Sourcepub fn kv(self, kv: impl KeyValue + 'static) -> Self
pub fn kv(self, kv: impl KeyValue + 'static) -> Self
The KeyValue port: RedisKv in this crate, or a test fake.
Sourcepub fn blob_arc(self, blob: Arc<dyn Blob>) -> Self
pub fn blob_arc(self, blob: Arc<dyn Blob>) -> Self
The Blob port: a directory store (crate::DirBlob) or an
S3-compatible adapter.
pub fn mailer(self, mailer: impl Mailer + 'static) -> Self
pub fn mailer_arc(self, mailer: Arc<dyn Mailer>) -> Self
pub fn captcha(self, captcha: impl Captcha + 'static) -> Self
pub fn captcha_arc(self, captcha: Arc<dyn Captcha>) -> Self
Sourcepub fn ports(&self) -> Ports
pub fn ports(&self) -> Ports
Resolves the port bundle once per process from the builder and
std::env: config, Signer (from HARNESS_SECRET — warn once
and leave unset when missing, exactly like the Cloudflare
runtime), HttpClient over reqwest, Clock over the system
clock, IdGen, and Defer over tokio::spawn.
Unlike the Workers runtime — which resolves bindings per event —
a native process builds one bundle and shares it: every adapter
here is an Arc, so clone_ports snapshots cheaply.