pub trait Function: Send + Sync {
// Required methods
fn manifest(&self) -> FunctionManifest;
fn invoke(
&self,
host: HostApi_TO<'_, RBox<()>>,
input: RStr<'_>,
) -> RResult<RString, RString>;
}Expand description
A loaded function instance. Constructed once per library via
FunctionMod::new_functions and reused across requests, so it must be
Send + Sync.
Required Methods§
Sourcefn manifest(&self) -> FunctionManifest
fn manifest(&self) -> FunctionManifest
Static metadata; called once right after construction.
Sourcefn invoke(
&self,
host: HostApi_TO<'_, RBox<()>>,
input: RStr<'_>,
) -> RResult<RString, RString>
fn invoke( &self, host: HostApi_TO<'_, RBox<()>>, input: RStr<'_>, ) -> RResult<RString, RString>
Handle a single request. input is the request body as JSON; the return
value is the JSON response body, or an error message the host turns into
a 400 — or a 500 when prefixed with INTERNAL_ERROR_PREFIX.
Must not unwind. This crosses an extern "C" boundary, so a panic
escaping it aborts the whole host process rather than failing the one
request; catch panics here and return INTERNAL_ERROR_PREFIX instead.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".