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 tracker_arc(self, tracker: Arc<dyn Tracker>) -> Self

The Tracker port: a cratefield_core::RoutingTracker over the per-tracker adapters the venture configured, or a test fake.

Unlike every other adapter on this harness, the adapter holds no credential: which tracker to file into and under whose token are tenant data, supplied per call by the module that files — see cratefield_core::Tracker for why that differs from the Resend/Stripe shape.

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 text_model(self, text_model: impl TextModel + 'static) -> Self

The TextModel port (issue #429): an adapter over the venture’s vendor of choice for each ModelTier, or one RoutingTextModel over both tiers. The same pattern as mailer.

Source

pub fn text_model_arc(self, text_model: Arc<dyn TextModel>) -> Self

text_model for an already-shared adapter.

Source

pub fn classifier(self, classifier: impl Classifier + 'static) -> Self

The Classifier port (issue #456): a typed, calibrated decision — “which of these is it, and how sure are you” — from a purpose-built classifier, a Workers AI binding (on the Workers twin) or an LLM behind the TextModel port. The same pattern as text_model.

Source

pub fn classifier_arc(self, classifier: Arc<dyn Classifier>) -> Self

classifier for an already-shared adapter.

Source

pub fn vector_index_arc(self, index: Arc<dyn VectorIndex>) -> Self

The VectorIndex port (issue #561): nearest-neighbour search over the namespaces a module asks for — in-process ExactVectorIndex or a hosted index’s adapter.

Source

pub fn embedder_arc(self, embedder: Arc<dyn Embedder>) -> Self

The Embedder port (issue #561): text into embedding vectors, as wide as the vector_index wired alongside it expects.

Source

pub fn custom_hostnames( self, custom_hostnames: impl CustomHostnames + 'static, ) -> Self

The CustomHostnames port (issue #590): a customer’s own hostname served by a venture. Like mailer, the adapter is built from the venture’s vendor keys and passed in — the Cloudflare for SaaS adapter is cratefield-adapter-cloudflare-saas, portable over the HttpClient port.

Source

pub fn custom_hostnames_arc( self, custom_hostnames: Arc<dyn CustomHostnames>, ) -> Self

custom_hostnames for an already-shared adapter.

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 auth(self, auth: impl Auth + 'static) -> Self

Wires who a request’s credentials speak for (issue #153).

Without one the deployment cannot identify a caller, and a module that declares Port::Auth is refused composition rather than mounted and left guessing.

Source

pub fn auth_arc(self, auth: Arc<dyn Auth>) -> Self

Source

pub fn auth_from_env(self) -> Self

Assembles the Auth port from AUTH_ISSUER and AUTH_CLIENT_ID.

The port is provided either way, matching the Cloudflare runtime: a venture generated by fz build wires this whenever one of its tables is not public-read, and the two runtimes answering differently for the same venture would be a difference between two deployments of one manifest.

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) -> Self

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() -> Self

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