pub struct Protocol { /* private fields */ }Expand description
A decoded protocol with reusable deterministic indices.
Construct this once when a server loads protocol.bin, then reuse it for
full renders, partial navigation, component-template requests, and token
queries. Full renders borrow the immutable protocol without locking.
Authored route patterns are precompiled once and matched as immutable
absolute patterns or relative suffixes. Parsed template metadata is
populated lazily behind a read-write lock whose scope is limited to
individual metadata lookups.
Implementations§
Source§impl Protocol
impl Protocol
Sourcepub fn from_protobuf(bytes: &[u8]) -> Result<Self, ProtocolError>
pub fn from_protobuf(bytes: &[u8]) -> Result<Self, ProtocolError>
Decode protobuf bytes and build the reusable protocol index.
§Errors
Returns a protocol error when bytes is not a valid WebUI protobuf.
Sourcepub fn new(protocol: WebUIProtocol) -> Self
pub fn new(protocol: WebUIProtocol) -> Self
Create a reusable runtime protocol from an already decoded document.
Sourcepub fn render_partial_json(
&self,
state_json: &str,
entry_id: &str,
request_path: &str,
inventory_hex: &str,
) -> Result<String, HandlerError>
pub fn render_partial_json( &self, state_json: &str, entry_id: &str, request_path: &str, inventory_hex: &str, ) -> Result<String, HandlerError>
Produce a complete partial-navigation response from serialized state.
This variant validates serialized host input while borrowing selected raw
values into the response. Rust callers that already own parsed state
should use Self::render_partial instead.
Sourcepub fn render_partial(
&self,
state: Value,
entry_id: &str,
request_path: &str,
inventory_hex: &str,
) -> Result<String, HandlerError>
pub fn render_partial( &self, state: Value, entry_id: &str, request_path: &str, inventory_hex: &str, ) -> Result<String, HandlerError>
Produce a complete partial-navigation response from parsed state.
This ownership-taking variant moves selected values into the response
instead of serializing and reparsing the complete state tree. Use it when
the caller already owns a serde_json::Value for the request.
Sourcepub fn prepare_partial(
&self,
state: Value,
entry_id: &str,
request_path: &str,
inventory_hex: &str,
) -> Result<PartialNavigation, HandlerError>
pub fn prepare_partial( &self, state: Value, entry_id: &str, request_path: &str, inventory_hex: &str, ) -> Result<PartialNavigation, HandlerError>
Prepare a serializable partial-navigation response with projected state.
Moves compiler-selected values from the caller’s owned state without
cloning the state tree. Unknown component surfaces retain full state for
correctness; reserved host injection state is excluded in either case.
The response includes PartialNavigation::is_match so hosts can decide
their HTTP status before serializing directly to their output buffer.
§Errors
Returns an error for invalid compiled style metadata or client inventory.
Sourcepub fn matches_route(&self, entry_id: &str, request_path: &str) -> bool
pub fn matches_route(&self, entry_id: &str, request_path: &str) -> bool
Test route existence using the compiled route matcher, without rendering component assets or serializing state.
Sourcepub fn render_component_templates(
&self,
component_tags: &[&str],
inventory_hex: &str,
) -> Result<Value, HandlerError>
pub fn render_component_templates( &self, component_tags: &[&str], inventory_hex: &str, ) -> Result<Value, HandlerError>
Render component template payloads for requested component tags.