Skip to main content

FunctionRuntime

Struct FunctionRuntime 

Source
pub struct FunctionRuntime { /* private fields */ }
Expand description

A reusable compute-to-data engine. Construct once per host; run is stateless apart from a compile cache keyed by the workload hash.

Implementations§

Source§

impl FunctionRuntime

Source

pub fn new() -> QueryResult<Self>

Construct the runtime. Fails as QueryError::Engine if wasmtime rejects the configuration on this host — a consumer gets an error to handle, not a panic.

Source

pub fn run( &self, module_wasm: &[u8], input: &[u8], limits: &RunLimits, ) -> QueryResult<Execution>

Run module_wasm’s run entry over input under limits, returning the output and its verifiable FunctionRun. module_wasm is the deployed .wasm (hashed as the workload identity).

Source

pub fn run_prehashed( &self, workload_hash: &[u8; 32], module_wasm: &[u8], input: &[u8], input_digest: Option<[u8; 32]>, limits: &RunLimits, ) -> QueryResult<Execution>

run with the module’s hash already known (a planner hashes each module once per query, not once per shard) and, when the caller has it, the input’s digest too (a pinned snapshot carries its own). The attestation is identical: these are the same values run computes.

Source§

impl FunctionRuntime

Source

pub fn validate_function(&self, module_wasm: &[u8]) -> QueryResult<()>

Deploy-time validation: the module may import only spacedb::host_call (and must speak the base ABI). Anything else is rejected before it can ever run — the allowlist is what keeps “deterministic” checkable.

Source

pub fn run_with_ctx( &self, module_wasm: &[u8], input: &[u8], limits: &RunLimits, ctx: FunctionCtx, ) -> QueryResult<FunctionOutcome>

Run a Database Function over input with ctx under limits. Reads come from the pinned snapshot (+ the run’s own writes); writes buffer into the ctx, returned for the caller to apply once on success. The attestation’s input_digest is hash(input ‖ snapshot_hash) so corroboration binds to the exact data the run saw.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.