pub trait CanvasHandler: Send + Sync {
// Required method
fn on_open<'life0, 'async_trait>(
&'life0 self,
ctx: CanvasProviderOpenRequest,
) -> Pin<Box<dyn Future<Output = CanvasResult<CanvasProviderOpenResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn on_action<'life0, 'async_trait>(
&'life0 self,
_ctx: CanvasProviderInvokeActionRequest,
) -> Pin<Box<dyn Future<Output = CanvasResult<Value>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn on_close<'life0, 'async_trait>(
&'life0 self,
_ctx: CanvasProviderCloseRequest,
) -> Pin<Box<dyn Future<Output = CanvasResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Provider-side canvas lifecycle handler.
Experimental. This trait is part of an experimental wire-protocol surface and may change or be removed in future SDK or CLI releases.
A session installs a single CanvasHandler (via
SessionConfig::with_canvas_handler).
The handler receives every inbound canvas.open / canvas.close /
canvas.action.invoke JSON-RPC request the runtime issues for this
session and decides — typically by inspecting
CanvasProviderOpenRequest::canvas_id
— which application-side canvas should handle the call.
The SDK does not maintain a per-canvas registry; multiplexing across declared canvases is the implementor’s responsibility.
Required Methods§
Sourcefn on_open<'life0, 'async_trait>(
&'life0 self,
ctx: CanvasProviderOpenRequest,
) -> Pin<Box<dyn Future<Output = CanvasResult<CanvasProviderOpenResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_open<'life0, 'async_trait>(
&'life0 self,
ctx: CanvasProviderOpenRequest,
) -> Pin<Box<dyn Future<Output = CanvasResult<CanvasProviderOpenResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Open a new canvas instance.
Provided Methods§
Sourcefn on_action<'life0, 'async_trait>(
&'life0 self,
_ctx: CanvasProviderInvokeActionRequest,
) -> Pin<Box<dyn Future<Output = CanvasResult<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_action<'life0, 'async_trait>(
&'life0 self,
_ctx: CanvasProviderInvokeActionRequest,
) -> Pin<Box<dyn Future<Output = CanvasResult<Value>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handle a non-lifecycle action declared by the canvas.
Sourcefn on_close<'life0, 'async_trait>(
&'life0 self,
_ctx: CanvasProviderCloseRequest,
) -> Pin<Box<dyn Future<Output = CanvasResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_close<'life0, 'async_trait>(
&'life0 self,
_ctx: CanvasProviderCloseRequest,
) -> Pin<Box<dyn Future<Output = CanvasResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Canvas was closed by the user or agent.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".