pub trait HandlerPlugin {
Show 15 methods
// Required methods
fn push_scope(&mut self);
fn pop_scope(&mut self);
fn on_binding_start(
&mut self,
name: &str,
writer: &mut dyn ResponseWriter,
) -> Result<()>;
fn on_binding_end(
&mut self,
name: &str,
writer: &mut dyn ResponseWriter,
) -> Result<()>;
fn on_repeat_item_start(
&mut self,
index: usize,
writer: &mut dyn ResponseWriter,
) -> Result<()>;
fn on_repeat_item_end(
&mut self,
index: usize,
writer: &mut dyn ResponseWriter,
) -> Result<()>;
fn on_element_data(
&mut self,
data: &[u8],
writer: &mut dyn ResponseWriter,
) -> Result<()>;
// Provided methods
fn on_for_start(
&mut self,
name: &str,
writer: &mut dyn ResponseWriter,
) -> Result<()> { ... }
fn on_for_end(
&mut self,
name: &str,
writer: &mut dyn ResponseWriter,
) -> Result<()> { ... }
fn on_if_start(
&mut self,
name: &str,
writer: &mut dyn ResponseWriter,
) -> Result<()> { ... }
fn on_if_end(
&mut self,
name: &str,
writer: &mut dyn ResponseWriter,
) -> Result<()> { ... }
fn write_route_component_state(
&self,
_state: &Value,
_writer: &mut dyn ResponseWriter,
) -> Result<()> { ... }
fn emit_templates(
&self,
protocol: &WebUIProtocol,
components: &HashSet<String>,
_nonce: Option<&str>,
writer: &mut dyn ResponseWriter,
) -> Result<()> { ... }
fn collect_template_payloads<'a>(
&self,
_protocol: &'a WebUIProtocol,
_components: &HashSet<String>,
) -> Option<Vec<WebUiTemplatePayload<'a>>> { ... }
fn emit_bootstrap_extension(
&self,
_context: BootstrapExtensionContext<'_>,
_writer: &mut dyn ResponseWriter,
) -> Result<()> { ... }
}Expand description
A handler plugin that can inject additional content during rendering.
Plugins receive callbacks at key points in the rendering lifecycle:
- Scope management:
push_scope/pop_scopefor component and loop boundaries - Binding lifecycle:
on_binding_start/on_binding_endaround signals - For-loop lifecycle:
on_for_start/on_for_endaround for-loop blocks - If-condition lifecycle:
on_if_start/on_if_endaround if-condition blocks - Repeat items:
on_repeat_item_start/on_repeat_item_endper for-loop item - Element data:
on_element_datafor parser-produced hydration metadata - Route state:
write_route_component_statefor framework-specific opening-tag attributes
WebUI does not interpret what plugins write — it just calls the hooks. Each framework defines its own marker format.
Required Methods§
Sourcefn push_scope(&mut self)
fn push_scope(&mut self)
Enter a new scope (component or for-loop item boundary). Typically resets per-scope counters.
Sourcefn on_binding_start(
&mut self,
name: &str,
writer: &mut dyn ResponseWriter,
) -> Result<()>
fn on_binding_start( &mut self, name: &str, writer: &mut dyn ResponseWriter, ) -> Result<()>
Called before rendering a signal binding.
Sourcefn on_binding_end(
&mut self,
name: &str,
writer: &mut dyn ResponseWriter,
) -> Result<()>
fn on_binding_end( &mut self, name: &str, writer: &mut dyn ResponseWriter, ) -> Result<()>
Called after rendering a signal binding.
Sourcefn on_repeat_item_start(
&mut self,
index: usize,
writer: &mut dyn ResponseWriter,
) -> Result<()>
fn on_repeat_item_start( &mut self, index: usize, writer: &mut dyn ResponseWriter, ) -> Result<()>
Called before rendering a repeat item in a for loop.
Sourcefn on_repeat_item_end(
&mut self,
index: usize,
writer: &mut dyn ResponseWriter,
) -> Result<()>
fn on_repeat_item_end( &mut self, index: usize, writer: &mut dyn ResponseWriter, ) -> Result<()>
Called after rendering a repeat item.
Sourcefn on_element_data(
&mut self,
data: &[u8],
writer: &mut dyn ResponseWriter,
) -> Result<()>
fn on_element_data( &mut self, data: &[u8], writer: &mut dyn ResponseWriter, ) -> Result<()>
Called when parser-produced element metadata is encountered.
Provided Methods§
Sourcefn on_for_start(
&mut self,
name: &str,
writer: &mut dyn ResponseWriter,
) -> Result<()>
fn on_for_start( &mut self, name: &str, writer: &mut dyn ResponseWriter, ) -> Result<()>
Called before rendering a for-loop block.
Defaults to on_binding_start.
Sourcefn on_for_end(
&mut self,
name: &str,
writer: &mut dyn ResponseWriter,
) -> Result<()>
fn on_for_end( &mut self, name: &str, writer: &mut dyn ResponseWriter, ) -> Result<()>
Called after rendering a for-loop block.
Defaults to on_binding_end.
Sourcefn on_if_start(
&mut self,
name: &str,
writer: &mut dyn ResponseWriter,
) -> Result<()>
fn on_if_start( &mut self, name: &str, writer: &mut dyn ResponseWriter, ) -> Result<()>
Called before rendering an if-condition block.
Defaults to on_binding_start.
Sourcefn on_if_end(
&mut self,
name: &str,
writer: &mut dyn ResponseWriter,
) -> Result<()>
fn on_if_end( &mut self, name: &str, writer: &mut dyn ResponseWriter, ) -> Result<()>
Called after rendering an if-condition block.
Defaults to on_binding_end.
Sourcefn write_route_component_state(
&self,
_state: &Value,
_writer: &mut dyn ResponseWriter,
) -> Result<()>
fn write_route_component_state( &self, _state: &Value, _writer: &mut dyn ResponseWriter, ) -> Result<()>
Called when emitting a matched route component’s opening tag.
Plugins can write framework-specific attributes before the closing >.
The default is a no-op.
Sourcefn emit_templates(
&self,
protocol: &WebUIProtocol,
components: &HashSet<String>,
_nonce: Option<&str>,
writer: &mut dyn ResponseWriter,
) -> Result<()>
fn emit_templates( &self, protocol: &WebUIProtocol, components: &HashSet<String>, _nonce: Option<&str>, writer: &mut dyn ResponseWriter, ) -> Result<()>
Emit component templates collected during SSR. The default emits
each template as-is (suitable for FAST <f-template> tags). The
WebUI split-payload path uses HandlerPlugin::collect_template_payloads
instead.
Sourcefn collect_template_payloads<'a>(
&self,
_protocol: &'a WebUIProtocol,
_components: &HashSet<String>,
) -> Option<Vec<WebUiTemplatePayload<'a>>>
fn collect_template_payloads<'a>( &self, _protocol: &'a WebUIProtocol, _components: &HashSet<String>, ) -> Option<Vec<WebUiTemplatePayload<'a>>>
Return split WebUI template payloads for the given components.
The WebUI plugin overrides this so lib.rs can emit JSON metadata in an
inert data block and only emit condition closures as executable JS.
Returns None when templates are non-WebUI payloads (e.g. FAST
<f-template> tags).
Sourcefn emit_bootstrap_extension(
&self,
_context: BootstrapExtensionContext<'_>,
_writer: &mut dyn ResponseWriter,
) -> Result<()>
fn emit_bootstrap_extension( &self, _context: BootstrapExtensionContext<'_>, _writer: &mut dyn ResponseWriter, ) -> Result<()>
Emit plugin-specific executable SSR bootstrap code, if needed.
The handler emits shared metadata as inert #webui-data; client
packages parse that data lazily. Plugins can still emit executable
side-channel data here, such as WebUI framework templateFns closures.
The default is a no-op for FAST plugins, which use <f-template> tags.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".