Skip to main content

Context

Struct Context 

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

Mutable context passed into LiveView lifecycle callbacks.

Implementations§

Source§

impl Context

Source

pub fn new(target_dom_id: impl Into<String>) -> Self

Create context for a new LiveView session.

Source

pub fn session_id(&self) -> &SessionId

The current session id.

Source

pub fn target_dom_id(&self) -> &str

The DOM id targeted by patches.

Source

pub fn route_path(&self) -> &str

Current request path for this LiveView session.

Source

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

Current route params matched by the transport adapter.

Source

pub fn route_param(&self, key: &str) -> Option<&str>

Borrow one current route param.

Source

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

Tenant context associated with this session.

Source

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

Set tenant context associated with this session.

Source

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

Replace tenant context associated with this session.

Source

pub fn clear_tenant_id(&mut self)

Clear tenant context associated with this session.

Source

pub fn is_connected(&self) -> bool

Whether this context is currently attached to a WebSocket.

Source

pub fn set_connected(&mut self, connected: bool)

Mark this context as connected or disconnected.

Source

pub fn push_message(&mut self, message: ServerMessage)

Queue an imperative server message.

Source

pub fn subscribe(&mut self, topic: impl Into<String>)

Subscribe this session to an in-process PubSub topic.

Source

pub fn broadcast( &mut self, topic: impl Into<String>, messages: Vec<ServerMessage>, )

Broadcast server messages to all subscribers on a topic.

Source

pub fn broadcast_message( &mut self, topic: impl Into<String>, message: ServerMessage, )

Broadcast one server message to all subscribers on a topic.

Source

pub fn schedule_once( &mut self, id: impl Into<String>, delay_ms: u64, event: impl Into<String>, value: impl Into<Value>, )

Schedule one synthetic event to be dispatched after delay_ms.

Source

pub fn schedule_once_to( &mut self, id: impl Into<String>, delay_ms: u64, target: impl Into<String>, event: impl Into<String>, value: impl Into<Value>, )

Schedule one synthetic scoped event to be dispatched after delay_ms.

Source

pub fn schedule_interval( &mut self, id: impl Into<String>, every_ms: u64, event: impl Into<String>, value: impl Into<Value>, )

Schedule a recurring synthetic event every every_ms.

Source

pub fn schedule_interval_to( &mut self, id: impl Into<String>, every_ms: u64, target: impl Into<String>, event: impl Into<String>, value: impl Into<Value>, )

Schedule a recurring scoped synthetic event every every_ms.

Source

pub fn cancel_schedule(&mut self, id: impl Into<String>)

Cancel a previously scheduled runtime command by id.

Source

pub fn request_render(&mut self)

Request a root render after the current event.

Source

pub fn set_render_cadence_ms(&mut self, cadence_ms: u64)

Override root render cadence for this session in milliseconds.

0 keeps immediate render behavior.

Source

pub fn clear_render_cadence_override(&mut self)

Clear any session-level render cadence override.

Source

pub fn skip_render(&mut self)

Suppress the automatic root render after the current event.

Source

pub fn redirect(&mut self, to: impl Into<String>)

Queue a browser redirect.

Source

pub fn patch_url(&mut self, to: impl Into<String>)

Queue a URL patch without replacing the current LiveView.

Source

pub fn navigate(&mut self, to: impl Into<String>)

Queue an internal LiveView navigation.

Source

pub fn stream_insert( &mut self, target: impl Into<String>, id: impl Into<String>, html: impl Into<String>, at: StreamPosition, )

Queue insertion of one item into a browser stream.

Source

pub fn stream_append( &mut self, target: impl Into<String>, id: impl Into<String>, html: impl Into<String>, )

Queue append of one item into a browser stream.

Source

pub fn stream_prepend( &mut self, target: impl Into<String>, id: impl Into<String>, html: impl Into<String>, )

Queue prepend of one item into a browser stream.

Source

pub fn stream_delete( &mut self, target: impl Into<String>, id: impl Into<String>, )

Queue deletion of one item from a browser stream.

Source

pub fn stream_batch( &mut self, target: impl Into<String>, operations: Vec<StreamBatchOperation>, )

Queue many stream operations as one protocol message.

Source

pub fn stream_append_many( &mut self, target: impl Into<String>, items: Vec<(String, String)>, )

Queue append of many items into a browser stream.

Source

pub fn stream_prepend_many( &mut self, target: impl Into<String>, items: Vec<(String, String)>, )

Queue prepend of many items into a browser stream.

Source

pub fn chart_series_append( &mut self, chart: impl Into<String>, series: impl Into<String>, point: ChartPoint, )

Queue append of one point into a browser-managed chart series.

Source

pub fn chart_series_append_many( &mut self, chart: impl Into<String>, series: impl Into<String>, points: Vec<ChartPoint>, )

Queue append of many points into one browser-managed chart series.

Source

pub fn chart_series_replace( &mut self, chart: impl Into<String>, series: impl Into<String>, points: Vec<ChartPoint>, )

Queue replacement of one chart series with a full point set.

Source

pub fn chart_reset(&mut self, chart: impl Into<String>)

Queue clearing of all series data for one chart.

Source

pub fn chart_annotation_upsert( &mut self, chart: impl Into<String>, annotation: ChartAnnotation, )

Queue insert or replacement of one chart annotation.

Source

pub fn chart_annotation_delete( &mut self, chart: impl Into<String>, id: impl Into<String>, )

Queue deletion of one chart annotation.

Source

pub fn toast_push(&mut self, toast: Toast)

Queue one toast notification for browser display.

Source

pub fn toast_dismiss(&mut self, id: impl Into<String>)

Queue dismissal of one toast notification.

Source

pub fn inbox_upsert(&mut self, item: InboxItem)

Queue insert or replacement of one inbox item.

Source

pub fn inbox_delete(&mut self, id: impl Into<String>)

Queue deletion of one inbox item.

Source

pub fn grid_replace(&mut self, grid: impl Into<String>, state: GridState)

Queue a full enterprise-grid snapshot update.

Source

pub fn grid_rows_replace( &mut self, grid: impl Into<String>, offset: usize, total_rows: usize, rows: Vec<GridRow>, )

Queue replacement of one active enterprise-grid row window.

Source

pub fn interop_dispatch( &mut self, event: impl Into<String>, detail: impl Into<Value>, )

Dispatch one browser interop event to document.

Source

pub fn interop_dispatch_to( &mut self, target: impl Into<Option<String>>, event: impl Into<String>, detail: impl Into<Value>, )

Dispatch one browser interop event to a specific target id.

Source

pub fn webrtc_signal(&mut self, detail: impl Into<Value>)

Dispatch one WebRTC signaling payload.

Source

pub fn webrtc_signal_to( &mut self, target: impl Into<String>, detail: impl Into<Value>, )

Dispatch one WebRTC signaling payload to a specific target id.

Trait Implementations§

Source§

impl Clone for Context

Source§

fn clone(&self) -> Context

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Context

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.