Skip to main content

TenantContext

Trait TenantContext 

Source
pub trait TenantContext {
    // Required method
    fn tenant_id(&self) -> TenantId;
}
Expand description

Trait for extracting the calling tenant from a wasmtime Store<T> payload.

The JIT dispatch host fn MUST build its CacheKey from the calling tenant’s identity (taken from trusted Store state) rather than from guest-supplied bytes. Wiring this through a trait keeps add_jit_dispatch_to_linker generic over T while still forcing every store type that wants to host the dispatch import to declare which tenant a given store belongs to.

This guards against the cross-tenant confused-deputy primitive documented on tensor_wasm_jit::cache::CacheKey: without the trait, the dispatch closure had no way to look up the calling tenant and was trusting the guest fingerprint alone.

Required Methods§

Source

fn tenant_id(&self) -> TenantId

The tenant this store belongs to. Returned to the dispatch closure on every host call so the cache lookup is scoped to the caller.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl TenantContext for ()

Test-only impl. Real production stores always carry an InstanceState; the unit type is used by the in-crate dispatcher unit tests (which spin up a Linker<()>). The synthetic tenant id keeps those tests on the same lookup key the test harness pre-populates the cache under.

Implementors§