Skip to main content

LiveSession

Struct LiveSession 

Source
pub struct LiveSession { /* private fields */ }
Expand description

Runtime holder for one connected LiveView instance.

Implementations§

Source§

impl LiveSession

Source

pub fn new(view: Box<dyn LiveView>, target_dom_id: impl Into<String>) -> Self

Create a new session from a boxed LiveView instance.

Source

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.

Source

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.

Source

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.

Source

pub fn set_telemetry_sink(&mut self, telemetry: Arc<dyn TelemetrySink>)

Set a telemetry sink for runtime/session instrumentation.

Source

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.

Source

pub fn mount(&mut self) -> LiveResult

Run the mount callback and mark the session as connected.

Source

pub fn drain_pubsub_commands(&mut self) -> Vec<PubSubCommand>

Drain PubSub commands queued by mount, params, or event handlers.

Source

pub fn drain_runtime_commands(&mut self) -> Vec<RuntimeCommand>

Drain runtime commands queued by mount, params, or event handlers.

Source

pub fn session_id(&self) -> &str

Session id used by protocol hello messages.

Source

pub fn route_path(&self) -> &str

Current internal route path tracked by the session.

Source

pub fn route_params(&self) -> &BTreeMap<String, String>

Current route params tracked by the session.

Source

pub fn tenant_id(&self) -> Option<&str>

Tenant context tracked by this session.

Source

pub fn set_tenant_id(&mut self, tenant_id: impl Into<String>)

Set tenant context for this session.

Source

pub fn set_tenant_id_optional(&mut self, tenant_id: Option<String>)

Replace tenant context for this session.

Source

pub fn revision(&self) -> u64

Current monotonic render revision.

Source

pub fn child_snapshots(&self) -> Vec<NestedLiveViewSnapshot>

Return snapshots for mounted, suspended, and terminated nested LiveViews.

Source

pub fn child_state(&self, id: impl AsRef<str>) -> Option<NestedLiveViewState>

Return the lifecycle state for one nested LiveView.

Source

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.

Source

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.

Source

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.

Source

pub fn suspend_child(&mut self, id: impl AsRef<str>) -> LiveResult

Suspend a child LiveView while keeping its server-side state.

Source

pub fn resume_child(&mut self, id: impl AsRef<str>) -> LiveResult<ServerMessage>

Resume a suspended child LiveView and return a child snapshot patch.

Source

pub fn terminate_child( &mut self, id: impl AsRef<str>, ) -> LiveResult<ServerMessage>

Terminate a child LiveView and patch its target to an empty body.

Source

pub fn enable_trace_capture(&mut self, policy: TraceRedactionPolicy)

Enable deterministic session trace capture.

Source

pub fn disable_trace_capture(&mut self)

Disable session trace capture and drop buffered trace state.

Source

pub fn trace_capture_enabled(&self) -> bool

Whether deterministic trace capture is currently enabled.

Source

pub fn trace_artifact(&self) -> Option<SessionReplayTrace>

Clone the current replay trace artifact, if capture is enabled.

Source

pub fn take_trace_artifact(&mut self) -> Option<SessionReplayTrace>

Move the replay trace artifact out of this session.

Source

pub fn render_html(&self) -> Html

Render the current view into an opaque HTML fragment.

Source

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.

Source

pub fn hello(&self) -> ServerMessage

Build the protocol hello message.

Source

pub fn render_patch(&mut self) -> ServerMessage

Render the current view as a browser patch.

Source

pub fn render_update(&mut self) -> ServerMessage

Render the current view as a dynamic diff when possible, otherwise a full patch.

Source

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.

Source

pub fn render_component_update( &mut self, render: ComponentRender, ) -> ServerMessage

Render one component as an independent browser patch.

Source

pub fn handle_client_message( &mut self, message: ClientMessage, ) -> Vec<ServerMessage>

Handle one client protocol message and return zero or more server messages.

Trait Implementations§

Source§

impl Drop for LiveSession

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.