Skip to main content

Protocol

Struct Protocol 

Source
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

Source

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.

Source

pub fn new(protocol: WebUIProtocol) -> Self

Create a reusable runtime protocol from an already decoded document.

Source

pub fn tokens(&self) -> &[String]

Borrow the build-time CSS token list.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn render_component_templates( &self, component_tags: &[&str], inventory_hex: &str, ) -> Result<Value, HandlerError>

Render component template payloads for requested component tags.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.