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
impl FunctionRuntime
Sourcepub fn new() -> QueryResult<Self>
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.
Sourcepub fn run(
&self,
module_wasm: &[u8],
input: &[u8],
limits: &RunLimits,
) -> QueryResult<Execution>
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).
Sourcepub fn run_prehashed(
&self,
workload_hash: &[u8; 32],
module_wasm: &[u8],
input: &[u8],
input_digest: Option<[u8; 32]>,
limits: &RunLimits,
) -> QueryResult<Execution>
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
impl FunctionRuntime
Sourcepub fn validate_function(&self, module_wasm: &[u8]) -> QueryResult<()>
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.
Sourcepub fn run_with_ctx(
&self,
module_wasm: &[u8],
input: &[u8],
limits: &RunLimits,
ctx: FunctionCtx,
) -> QueryResult<FunctionOutcome>
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§
impl !Freeze for FunctionRuntime
impl !RefUnwindSafe for FunctionRuntime
impl !UnwindSafe for FunctionRuntime
impl Forget for FunctionRuntime
impl Send for FunctionRuntime
impl Sync for FunctionRuntime
impl Unpin for FunctionRuntime
impl UnsafeUnpin for FunctionRuntime
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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