pub struct Controller { /* private fields */ }Expand description
Per-execution controller. Not thread-safe — use one at a time. Can be reused across invocations by swapping the host context. WASM linear memory persists between calls, so Rust statics survive.
Implementations§
Source§impl Controller
impl Controller
Sourcepub fn set_context(&mut self, context: Box<dyn InvocationContext>)
pub fn set_context(&mut self, context: Box<dyn InvocationContext>)
Replace the invocation context. Used when reusing a pooled controller
for a new request with different permissions. Also updates the WASI
stdio callbacks so guest println! output routes through the same
structured logging path as the WIT stdout/stderr imports.
Sourcepub fn clear_context(&mut self)
pub fn clear_context(&mut self)
Clear the invocation context, replacing it with a NullContext. Called before returning a controller to the pool so no per-request state (auth, permissions, KV) is retained. Resets WASI stdio to host defaults.
Sourcepub fn reset_epoch_deadline(&mut self)
pub fn reset_epoch_deadline(&mut self)
Reset the epoch deadline to the maximum safe value. Wasmtime internally
computes current_epoch + delta with wrapping arithmetic, so passing
u64::MAX overflows once the epoch advances past 0. We subtract the
shadow counter (always >= engine epoch thanks to the ticker thread
increment ordering) plus a small margin so that a concurrent tick
between the load and the set_epoch_deadline call cannot overflow.
pub async fn init(&mut self) -> SurrealismResult<()>
pub async fn invoke<A: Args>( &mut self, name: Option<String>, args: A, ) -> SurrealismResult<Value>
Sourcepub async fn invoke_with_timeout<A: Args>(
&mut self,
name: Option<String>,
args: A,
context_timeout: Option<Duration>,
) -> SurrealismResult<Value>
pub async fn invoke_with_timeout<A: Args>( &mut self, name: Option<String>, args: A, context_timeout: Option<Duration>, ) -> SurrealismResult<Value>
Invoke with an optional context-level timeout. The effective deadline is
min(context_remaining, module_config, server_cap).
Sourcepub async fn args(
&mut self,
name: Option<String>,
) -> SurrealismResult<Vec<(String, Kind)>>
pub async fn args( &mut self, name: Option<String>, ) -> SurrealismResult<Vec<(String, Kind)>>
Query named argument types for a function via the WASM export.
Only available when the module has the function-args export (build tool).
Sourcepub async fn returns(&mut self, name: Option<String>) -> SurrealismResult<Kind>
pub async fn returns(&mut self, name: Option<String>) -> SurrealismResult<Kind>
Query return type for a function via the WASM export.
Only available when the module has the function-returns export (build tool).
Sourcepub async fn writeable(
&mut self,
name: Option<String>,
) -> SurrealismResult<bool>
pub async fn writeable( &mut self, name: Option<String>, ) -> SurrealismResult<bool>
Query whether a function is marked as writeable via the WASM export.
Only available when the module has the function-writeable export (build tool).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Controller
impl !RefUnwindSafe for Controller
impl Send for Controller
impl !Sync for Controller
impl Unpin for Controller
impl UnsafeUnpin for Controller
impl !UnwindSafe for Controller
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> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
self file descriptor. Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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