pub struct LiveSession { /* private fields */ }Expand description
Runtime holder for one connected LiveView instance.
Implementations§
Source§impl LiveSession
impl LiveSession
Sourcepub fn new(view: Box<dyn LiveView>, target_dom_id: impl Into<String>) -> Self
pub fn new(view: Box<dyn LiveView>, target_dom_id: impl Into<String>) -> Self
Create a new session from a boxed LiveView instance.
Sourcepub fn new_with_session_id(
view: Box<dyn LiveView>,
session_id: impl Into<String>,
target_dom_id: impl Into<String>,
) -> Self
pub fn new_with_session_id( view: Box<dyn LiveView>, session_id: impl Into<String>, target_dom_id: impl Into<String>, ) -> Self
Create a new session with an existing signed session id.
Sourcepub fn new_with_route(
view: Box<dyn LiveView>,
target_dom_id: impl Into<String>,
route_path: impl Into<String>,
route_params: BTreeMap<String, String>,
) -> Self
pub fn new_with_route( view: Box<dyn LiveView>, target_dom_id: impl Into<String>, route_path: impl Into<String>, route_params: BTreeMap<String, String>, ) -> Self
Create a new session with adapter-matched route data.
Sourcepub fn new_with_route_and_session_id(
view: Box<dyn LiveView>,
session_id: impl Into<String>,
target_dom_id: impl Into<String>,
route_path: impl Into<String>,
route_params: BTreeMap<String, String>,
) -> Self
pub fn new_with_route_and_session_id( view: Box<dyn LiveView>, session_id: impl Into<String>, target_dom_id: impl Into<String>, route_path: impl Into<String>, route_params: BTreeMap<String, String>, ) -> Self
Create a new session with an existing signed session id and route data.
Sourcepub fn set_telemetry_sink(&mut self, telemetry: Arc<dyn TelemetrySink>)
pub fn set_telemetry_sink(&mut self, telemetry: Arc<dyn TelemetrySink>)
Set a telemetry sink for runtime/session instrumentation.
Sourcepub fn set_default_render_cadence_ms(&mut self, cadence_ms: u64)
pub fn set_default_render_cadence_ms(&mut self, cadence_ms: u64)
Configure default root-render cadence in milliseconds.
A value of 0 keeps immediate render behavior.
Sourcepub fn mount(&mut self) -> LiveResult
pub fn mount(&mut self) -> LiveResult
Run the mount callback and mark the session as connected.
Sourcepub fn drain_pubsub_commands(&mut self) -> Vec<PubSubCommand>
pub fn drain_pubsub_commands(&mut self) -> Vec<PubSubCommand>
Drain PubSub commands queued by mount, params, or event handlers.
Sourcepub fn drain_runtime_commands(&mut self) -> Vec<RuntimeCommand>
pub fn drain_runtime_commands(&mut self) -> Vec<RuntimeCommand>
Drain runtime commands queued by mount, params, or event handlers.
Sourcepub fn session_id(&self) -> &str
pub fn session_id(&self) -> &str
Session id used by protocol hello messages.
Sourcepub fn route_path(&self) -> &str
pub fn route_path(&self) -> &str
Current internal route path tracked by the session.
Sourcepub fn route_params(&self) -> &BTreeMap<String, String>
pub fn route_params(&self) -> &BTreeMap<String, String>
Current route params tracked by the session.
Sourcepub fn set_tenant_id(&mut self, tenant_id: impl Into<String>)
pub fn set_tenant_id(&mut self, tenant_id: impl Into<String>)
Set tenant context for this session.
Sourcepub fn set_tenant_id_optional(&mut self, tenant_id: Option<String>)
pub fn set_tenant_id_optional(&mut self, tenant_id: Option<String>)
Replace tenant context for this session.
Sourcepub fn child_snapshots(&self) -> Vec<NestedLiveViewSnapshot>
pub fn child_snapshots(&self) -> Vec<NestedLiveViewSnapshot>
Return snapshots for mounted, suspended, and terminated nested LiveViews.
Sourcepub fn child_state(&self, id: impl AsRef<str>) -> Option<NestedLiveViewState>
pub fn child_state(&self, id: impl AsRef<str>) -> Option<NestedLiveViewState>
Return the lifecycle state for one nested LiveView.
Sourcepub fn mount_child(
&mut self,
id: impl Into<NestedLiveViewId>,
view: Box<dyn LiveView>,
target_dom_id: impl Into<String>,
) -> LiveResult<ServerMessage>
pub fn mount_child( &mut self, id: impl Into<NestedLiveViewId>, view: Box<dyn LiveView>, target_dom_id: impl Into<String>, ) -> LiveResult<ServerMessage>
Mount a child LiveView under this session and return its initial patch.
Sourcepub fn mount_child_with_route(
&mut self,
id: impl Into<NestedLiveViewId>,
view: Box<dyn LiveView>,
target_dom_id: impl Into<String>,
route_path: impl Into<String>,
route_params: BTreeMap<String, String>,
) -> LiveResult<ServerMessage>
pub fn mount_child_with_route( &mut self, id: impl Into<NestedLiveViewId>, view: Box<dyn LiveView>, target_dom_id: impl Into<String>, route_path: impl Into<String>, route_params: BTreeMap<String, String>, ) -> LiveResult<ServerMessage>
Mount a child LiveView with explicit route data and return its initial patch.
Sourcepub fn update_child_params(
&mut self,
id: impl AsRef<str>,
route_path: impl Into<String>,
route_params: BTreeMap<String, String>,
) -> LiveResult<ServerMessage>
pub fn update_child_params( &mut self, id: impl AsRef<str>, route_path: impl Into<String>, route_params: BTreeMap<String, String>, ) -> LiveResult<ServerMessage>
Update route params for a mounted child LiveView and return a child patch.
Sourcepub fn suspend_child(&mut self, id: impl AsRef<str>) -> LiveResult
pub fn suspend_child(&mut self, id: impl AsRef<str>) -> LiveResult
Suspend a child LiveView while keeping its server-side state.
Sourcepub fn resume_child(&mut self, id: impl AsRef<str>) -> LiveResult<ServerMessage>
pub fn resume_child(&mut self, id: impl AsRef<str>) -> LiveResult<ServerMessage>
Resume a suspended child LiveView and return a child snapshot patch.
Sourcepub fn terminate_child(
&mut self,
id: impl AsRef<str>,
) -> LiveResult<ServerMessage>
pub fn terminate_child( &mut self, id: impl AsRef<str>, ) -> LiveResult<ServerMessage>
Terminate a child LiveView and patch its target to an empty body.
Sourcepub fn enable_trace_capture(&mut self, policy: TraceRedactionPolicy)
pub fn enable_trace_capture(&mut self, policy: TraceRedactionPolicy)
Enable deterministic session trace capture.
Sourcepub fn disable_trace_capture(&mut self)
pub fn disable_trace_capture(&mut self)
Disable session trace capture and drop buffered trace state.
Sourcepub fn trace_capture_enabled(&self) -> bool
pub fn trace_capture_enabled(&self) -> bool
Whether deterministic trace capture is currently enabled.
Sourcepub fn trace_artifact(&self) -> Option<SessionReplayTrace>
pub fn trace_artifact(&self) -> Option<SessionReplayTrace>
Clone the current replay trace artifact, if capture is enabled.
Sourcepub fn take_trace_artifact(&mut self) -> Option<SessionReplayTrace>
pub fn take_trace_artifact(&mut self) -> Option<SessionReplayTrace>
Move the replay trace artifact out of this session.
Sourcepub fn render_html(&self) -> Html
pub fn render_html(&self) -> Html
Render the current view into an opaque HTML fragment.
Sourcepub fn patch_route(
&mut self,
route_path: impl Into<String>,
route_params: BTreeMap<String, String>,
) -> LiveResult
pub fn patch_route( &mut self, route_path: impl Into<String>, route_params: BTreeMap<String, String>, ) -> LiveResult
Update route data and call the view’s route-param hook.
Sourcepub fn hello(&self) -> ServerMessage
pub fn hello(&self) -> ServerMessage
Build the protocol hello message.
Sourcepub fn render_patch(&mut self) -> ServerMessage
pub fn render_patch(&mut self) -> ServerMessage
Render the current view as a browser patch.
Sourcepub fn render_update(&mut self) -> ServerMessage
pub fn render_update(&mut self) -> ServerMessage
Render the current view as a dynamic diff when possible, otherwise a full patch.
Sourcepub fn render_snapshot_patch(&mut self) -> ServerMessage
pub fn render_snapshot_patch(&mut self) -> ServerMessage
Render the current view into a patch at the current revision.
This is used by reconnect reconciliation paths where the server must resend the latest snapshot without incrementing revision.
Sourcepub fn render_component_update(
&mut self,
render: ComponentRender,
) -> ServerMessage
pub fn render_component_update( &mut self, render: ComponentRender, ) -> ServerMessage
Render one component as an independent browser patch.
Sourcepub fn handle_client_message(
&mut self,
message: ClientMessage,
) -> Vec<ServerMessage>
pub fn handle_client_message( &mut self, message: ClientMessage, ) -> Vec<ServerMessage>
Handle one client protocol message and return zero or more server messages.