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.
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>
This function called to convert napi values to native rust values Read more
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>
This function called to convert napi values to native rust values Read more
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>
This function called to convert rust values to napi values Read more
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>
This function called to validate whether napi value passed to rust is valid type. Read more
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>
This function called to validate whether napi value passed to rust is valid type. Read more
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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