pub struct Protocol { /* private fields */ }Expand description
A decoded protocol and its reusable deterministic indices.
Create this once when a Node server loads protocol.bin, then reuse it for
full renders, partial navigation, component loading, and token queries. The
selected hydration plugin is bound once at construction.
Implementations§
Source§impl Protocol
impl Protocol
Sourcepub fn new(protocol_data: Buffer, plugin: Option<String>) -> Result<Self>
pub fn new(protocol_data: Buffer, plugin: Option<String>) -> Result<Self>
Decode a protocol and bind its render plugin for repeated rendering.
Sourcepub fn render(
&self,
state_json: String,
entry: String,
request_path: String,
) -> Result<Buffer>
pub fn render( &self, state_json: String, entry: String, request_path: String, ) -> Result<Buffer>
Render from an existing JSON string into a UTF-8 Node.js buffer.
Sourcepub fn render_stream(
&self,
state_json: String,
entry: String,
request_path: String,
on_chunk: Function<'_, String>,
) -> Result<()>
pub fn render_stream( &self, state_json: String, entry: String, request_path: String, on_chunk: Function<'_, String>, ) -> Result<()>
Stream an existing JSON string in bounded chunks.
Sourcepub fn render_partial(
&self,
state_json: String,
entry_id: String,
request_path: String,
inventory_hex: String,
) -> Result<String>
pub fn render_partial( &self, state_json: String, entry_id: String, request_path: String, inventory_hex: String, ) -> Result<String>
Produce a complete partial-navigation response.
Sourcepub fn render_component_templates(
&self,
component_tags: Vec<String>,
inventory_hex: String,
) -> Result<String>
pub fn render_component_templates( &self, component_tags: Vec<String>, inventory_hex: String, ) -> Result<String>
Render component templates and styles for on-demand loading.
Sourcepub fn stream_response(
&self,
entry: String,
request_path: String,
options: Option<JsStreamOptions>,
) -> Result<StreamingSession>
pub fn stream_response( &self, entry: String, request_path: String, options: Option<JsStreamOptions>, ) -> Result<StreamingSession>
Open a host-driven progressive response for a streaming entry.
Unlike renderStream, which pushes every chunk during one synchronous
call, the returned session hands each chunk back so the Node server
owns the socket, the write order, and backpressure.
Trait Implementations§
Source§impl FromNapiMutRef for Protocol
impl FromNapiMutRef for Protocol
Source§unsafe fn from_napi_mut_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static mut Self>
unsafe fn from_napi_mut_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static mut Self>
Source§impl FromNapiRef for Protocol
impl FromNapiRef for Protocol
Source§unsafe fn from_napi_ref(
env: napi_env,
napi_val: napi_value,
) -> Result<&'static Self>
unsafe fn from_napi_ref( env: napi_env, napi_val: napi_value, ) -> Result<&'static Self>
Source§impl JavaScriptClassExt for Protocol
impl JavaScriptClassExt for Protocol
fn into_instance<'scope>( self, env: &'scope Env, ) -> Result<ClassInstance<'scope, Self>>
fn into_reference(self, env: Env) -> Result<Reference<Self>>
fn instance_of<'env, V: JsValue<'env>>(env: &Env, value: &V) -> Result<bool>
Source§impl ToNapiValue for Protocol
impl ToNapiValue for Protocol
Source§unsafe fn to_napi_value(env: napi_env, val: Protocol) -> Result<napi_value>
unsafe fn to_napi_value(env: napi_env, val: Protocol) -> Result<napi_value>
fn into_unknown(self, env: &Env) -> Result<Unknown<'_>, Error>
Source§impl ValidateNapiValue for &Protocol
impl ValidateNapiValue for &Protocol
Source§unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
Source§impl ValidateNapiValue for &mut Protocol
impl ValidateNapiValue for &mut Protocol
Source§unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
unsafe fn validate(env: napi_env, napi_val: napi_value) -> Result<napi_value>
Auto Trait Implementations§
impl Freeze for Protocol
impl RefUnwindSafe for Protocol
impl Send for Protocol
impl Sync for Protocol
impl Unpin for Protocol
impl UnsafeUnpin for Protocol
impl UnwindSafe for Protocol
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more