Skip to main content

Native

Struct Native 

Source
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

Source

pub fn new() -> Self

Source

pub fn db(self, db: impl Database + 'static) -> Self

The Database port: Postgres (cratefield-adapter-postgres) or SqliteDatabase (cratefield-adapter-sqlite) — any Database implementation.

Source

pub fn db_arc(self, db: Arc<dyn Database>) -> Self

db for an already-shared database.

Source

pub fn rate_limiter(self, limiter: impl RateLimiter + 'static) -> Self

The RateLimiter port: RedisRateLimiter in this crate, or a test fake.

Source

pub fn rate_limiter_arc(self, limiter: Arc<dyn RateLimiter>) -> Self

rate_limiter for an already-shared limiter.

Source

pub fn kv(self, kv: impl KeyValue + 'static) -> Self

The KeyValue port: RedisKv in this crate, or a test fake.

Source

pub fn kv_arc(self, kv: Arc<dyn KeyValue>) -> Self

kv for an already-shared store.

Source

pub fn blob_arc(self, blob: Arc<dyn Blob>) -> Self

The Blob port: a directory store (crate::DirBlob) or an S3-compatible adapter.

Source

pub fn push_arc(self, push: Arc<dyn Push>) -> Self

The Push port: an APNs adapter (cratefield-adapter-apns) or a test fake. Notifications reach a device over the runtime’s HttpClient.

Source

pub fn payments_arc(self, payments: Arc<dyn Payments>) -> Self

The Payments port: a Stripe adapter (cratefield-adapter-stripe) or a test fake, over the runtime’s HttpClient.

Source

pub fn realtime_arc(self, realtime: Arc<dyn Realtime>) -> Self

The Realtime port: the in-process room registry (crate::InProcessRealtime) built from the module’s RoomHandler.

Source

pub fn mailer(self, mailer: impl Mailer + 'static) -> Self

Source

pub fn mailer_arc(self, mailer: Arc<dyn Mailer>) -> Self

Source

pub fn captcha(self, captcha: impl Captcha + 'static) -> Self

Source

pub fn captcha_arc(self, captcha: Arc<dyn Captcha>) -> Self

Source

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.

Trait Implementations§

Source§

impl Clone for Native

Source§

fn clone(&self) -> Native

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Native

Source§

fn default() -> Native

Returns the “default value” for a type. Read more
Source§

impl Runtime for Native

Source§

fn provides(&self) -> Vec<Port>

The static set used by Harness::build. Signer is included: its presence is validated at ports() time (and by fz doctor), mirroring the Cloudflare runtime.

Source§

fn effectively_configured(&self, port: Port) -> bool

The same production gate the Cloudflare runtime applies (issue #133), which this runtime never did (issue #143): a Turnstile adapter that is not hostname-bound, or left fail-open, cannot protect a production HumanForm route, so the port is present but not usable. Without this a self-hosted venture booted past a check its Workers twin refuses. Adapters that do not report (binding() == None) count as effective when present: presence is all the runtime can know about them.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more