pub trait InvocationHandler<Marker>: Sealed<Marker> { }Expand description
An async function that handles POST /invocations.
It is implemented for functions and closures with these signatures:
async fn(Req) -> Result<O, E>async fn(Req, RequestContext) -> Result<O, E>
Req is any DeserializeOwned type, for example serde_json::Value for an
untyped payload. O is any IntoInvocationResponse type. E converts into a
boxed error and its Display text becomes the 500 error body.
The handler and the future that it returns must be Send, and the handler must be
Sync + 'static. Req must be Send + 'static, the boxed error must be
Send + Sync, and both arguments are taken by value, in this order.
A handler that panics gets 500 {"error": "Internal error"} and the server keeps
running. So does a panic in the conversion or the Display of the error that the
handler returned. This holds for unwinding panics only, not with panic = "abort".
§Blocking work
A handler must not block its thread, for example with std::thread::sleep or
synchronous I/O. Blocking work belongs in tokio::task::spawn_blocking.
BedrockAgentCoreApp::run describes what a
handler that blocks delays.
The Marker parameter only separates the two signatures. The compiler infers it.
This trait is sealed. Other crates cannot implement it.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".