pub struct Context { /* private fields */ }Expand description
Mutable context passed into LiveView lifecycle callbacks.
Implementations§
Source§impl Context
impl Context
Sourcepub fn new(target_dom_id: impl Into<String>) -> Self
pub fn new(target_dom_id: impl Into<String>) -> Self
Create context for a new LiveView session.
Sourcepub fn session_id(&self) -> &SessionId
pub fn session_id(&self) -> &SessionId
The current session id.
Sourcepub fn target_dom_id(&self) -> &str
pub fn target_dom_id(&self) -> &str
The DOM id targeted by patches.
Sourcepub fn route_path(&self) -> &str
pub fn route_path(&self) -> &str
Current request path for this LiveView session.
Sourcepub fn route_params(&self) -> &BTreeMap<String, String>
pub fn route_params(&self) -> &BTreeMap<String, String>
Current route params matched by the transport adapter.
Sourcepub fn route_param(&self, key: &str) -> Option<&str>
pub fn route_param(&self, key: &str) -> Option<&str>
Borrow one current route param.
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 associated with 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 associated with this session.
Sourcepub fn clear_tenant_id(&mut self)
pub fn clear_tenant_id(&mut self)
Clear tenant context associated with this session.
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Whether this context is currently attached to a WebSocket.
Sourcepub fn set_connected(&mut self, connected: bool)
pub fn set_connected(&mut self, connected: bool)
Mark this context as connected or disconnected.
Sourcepub fn push_message(&mut self, message: ServerMessage)
pub fn push_message(&mut self, message: ServerMessage)
Queue an imperative server message.
Sourcepub fn subscribe(&mut self, topic: impl Into<String>)
pub fn subscribe(&mut self, topic: impl Into<String>)
Subscribe this session to an in-process PubSub topic.
Sourcepub fn broadcast(
&mut self,
topic: impl Into<String>,
messages: Vec<ServerMessage>,
)
pub fn broadcast( &mut self, topic: impl Into<String>, messages: Vec<ServerMessage>, )
Broadcast server messages to all subscribers on a topic.
Sourcepub fn broadcast_message(
&mut self,
topic: impl Into<String>,
message: ServerMessage,
)
pub fn broadcast_message( &mut self, topic: impl Into<String>, message: ServerMessage, )
Broadcast one server message to all subscribers on a topic.
Sourcepub fn schedule_once(
&mut self,
id: impl Into<String>,
delay_ms: u64,
event: impl Into<String>,
value: impl Into<Value>,
)
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.
Sourcepub 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>,
)
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.
Sourcepub fn schedule_interval(
&mut self,
id: impl Into<String>,
every_ms: u64,
event: impl Into<String>,
value: impl Into<Value>,
)
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.
Sourcepub 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>,
)
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.
Sourcepub fn cancel_schedule(&mut self, id: impl Into<String>)
pub fn cancel_schedule(&mut self, id: impl Into<String>)
Cancel a previously scheduled runtime command by id.
Sourcepub fn request_render(&mut self)
pub fn request_render(&mut self)
Request a root render after the current event.
Sourcepub fn set_render_cadence_ms(&mut self, cadence_ms: u64)
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.
Sourcepub fn clear_render_cadence_override(&mut self)
pub fn clear_render_cadence_override(&mut self)
Clear any session-level render cadence override.
Sourcepub fn skip_render(&mut self)
pub fn skip_render(&mut self)
Suppress the automatic root render after the current event.
Sourcepub fn patch_url(&mut self, to: impl Into<String>)
pub fn patch_url(&mut self, to: impl Into<String>)
Queue a URL patch without replacing the current LiveView.
Queue an internal LiveView navigation.
Sourcepub fn stream_insert(
&mut self,
target: impl Into<String>,
id: impl Into<String>,
html: impl Into<String>,
at: StreamPosition,
)
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.
Sourcepub fn stream_append(
&mut self,
target: impl Into<String>,
id: impl Into<String>,
html: impl Into<String>,
)
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.
Sourcepub fn stream_prepend(
&mut self,
target: impl Into<String>,
id: impl Into<String>,
html: impl Into<String>,
)
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.
Sourcepub fn stream_delete(
&mut self,
target: impl Into<String>,
id: impl Into<String>,
)
pub fn stream_delete( &mut self, target: impl Into<String>, id: impl Into<String>, )
Queue deletion of one item from a browser stream.
Sourcepub fn stream_batch(
&mut self,
target: impl Into<String>,
operations: Vec<StreamBatchOperation>,
)
pub fn stream_batch( &mut self, target: impl Into<String>, operations: Vec<StreamBatchOperation>, )
Queue many stream operations as one protocol message.
Sourcepub fn stream_append_many(
&mut self,
target: impl Into<String>,
items: Vec<(String, String)>,
)
pub fn stream_append_many( &mut self, target: impl Into<String>, items: Vec<(String, String)>, )
Queue append of many items into a browser stream.
Sourcepub fn stream_prepend_many(
&mut self,
target: impl Into<String>,
items: Vec<(String, String)>,
)
pub fn stream_prepend_many( &mut self, target: impl Into<String>, items: Vec<(String, String)>, )
Queue prepend of many items into a browser stream.
Sourcepub fn chart_series_append(
&mut self,
chart: impl Into<String>,
series: impl Into<String>,
point: ChartPoint,
)
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.
Sourcepub fn chart_series_append_many(
&mut self,
chart: impl Into<String>,
series: impl Into<String>,
points: Vec<ChartPoint>,
)
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.
Sourcepub fn chart_series_replace(
&mut self,
chart: impl Into<String>,
series: impl Into<String>,
points: Vec<ChartPoint>,
)
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.
Sourcepub fn chart_reset(&mut self, chart: impl Into<String>)
pub fn chart_reset(&mut self, chart: impl Into<String>)
Queue clearing of all series data for one chart.
Sourcepub fn chart_annotation_upsert(
&mut self,
chart: impl Into<String>,
annotation: ChartAnnotation,
)
pub fn chart_annotation_upsert( &mut self, chart: impl Into<String>, annotation: ChartAnnotation, )
Queue insert or replacement of one chart annotation.
Sourcepub fn chart_annotation_delete(
&mut self,
chart: impl Into<String>,
id: impl Into<String>,
)
pub fn chart_annotation_delete( &mut self, chart: impl Into<String>, id: impl Into<String>, )
Queue deletion of one chart annotation.
Sourcepub fn toast_push(&mut self, toast: Toast)
pub fn toast_push(&mut self, toast: Toast)
Queue one toast notification for browser display.
Sourcepub fn toast_dismiss(&mut self, id: impl Into<String>)
pub fn toast_dismiss(&mut self, id: impl Into<String>)
Queue dismissal of one toast notification.
Sourcepub fn inbox_upsert(&mut self, item: InboxItem)
pub fn inbox_upsert(&mut self, item: InboxItem)
Queue insert or replacement of one inbox item.
Sourcepub fn inbox_delete(&mut self, id: impl Into<String>)
pub fn inbox_delete(&mut self, id: impl Into<String>)
Queue deletion of one inbox item.
Sourcepub fn grid_replace(&mut self, grid: impl Into<String>, state: GridState)
pub fn grid_replace(&mut self, grid: impl Into<String>, state: GridState)
Queue a full enterprise-grid snapshot update.
Sourcepub fn grid_rows_replace(
&mut self,
grid: impl Into<String>,
offset: usize,
total_rows: usize,
rows: Vec<GridRow>,
)
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.
Sourcepub fn interop_dispatch(
&mut self,
event: impl Into<String>,
detail: impl Into<Value>,
)
pub fn interop_dispatch( &mut self, event: impl Into<String>, detail: impl Into<Value>, )
Dispatch one browser interop event to document.
Sourcepub fn interop_dispatch_to(
&mut self,
target: impl Into<Option<String>>,
event: impl Into<String>,
detail: impl Into<Value>,
)
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.
Sourcepub fn webrtc_signal(&mut self, detail: impl Into<Value>)
pub fn webrtc_signal(&mut self, detail: impl Into<Value>)
Dispatch one WebRTC signaling payload.