Expand description
Core runtime primitives for Shelly LiveView.
This crate intentionally avoids HTTP concerns. It defines the framework
contract: events, server messages, HTML rendering, session lifecycle, and
the LiveView trait.
§Quick Example
use shelly::{Context, Event, Html, LiveResult, LiveView};
#[derive(Default)]
struct Counter {
count: i64,
}
impl LiveView for Counter {
fn handle_event(&mut self, event: Event, _ctx: &mut Context) -> LiveResult {
if event.name == "inc" {
self.count += 1;
}
Ok(())
}
fn render(&self) -> Html {
Html::new(format!("<h1>{}</h1>", self.count))
}
}
let mut view = Counter::default();
let mut ctx = Context::new("root");
view.handle_event(Event::new("inc"), &mut ctx).expect("event should succeed");
assert_eq!(view.render().as_str(), "<h1>1</h1>");Structs§
- Chart
Annotation - One chart annotation marker.
- Chart
Point - One numeric chart point.
- Component
Id - Stable server-owned identifier for a LiveComponent.
- Component
Render - Render result for one component after a scoped event.
- Context
- Mutable context passed into LiveView lifecycle callbacks.
- Dynamic
Slot Patch - Dynamic slot update sent by a
diffserver message. - Event
- A normalized browser event delivered to a LiveView.
- Form
Data - Path-aware reader for nested form payloads.
- Grid
Column - One grid column descriptor.
- GridRow
- One grid row record.
- Grid
Rows Window - Active window rows for one grid snapshot.
- Grid
Saved View - One saved grid view.
- Grid
Sort - Active grid sort definition.
- Grid
State - Full browser-managed data-grid state.
- Html
- A server-rendered HTML fragment.
- Inbox
Item - One inbox item shown by the browser runtime.
- JsInterop
Dispatch - One browser interop dispatch instruction.
- Live
Session - Runtime holder for one connected LiveView instance.
- Memory
Telemetry Sink - Nested
Live View Id - Stable server-owned identifier for a nested LiveView instance.
- Nested
Live View Snapshot - Public snapshot of one nested LiveView runtime boundary.
- Noop
Telemetry Sink - Protocol
Instruction Descriptor - Protocol
Invariant Violation - PubSub
- Adapter-owned PubSub runtime abstraction.
- PubSub
Capabilities - Cluster capabilities advertised by a PubSub backend.
- PubSub
Message - Message delivered by one PubSub backend.
- PubSub
Presence Snapshot - Presence snapshot for one topic across nodes.
- PubSub
Subscription - Live subscription receiver for one topic.
- Replay
Report - Replay
Step Result - Runtime
Event - Structured event payload emitted by adapter-managed runtime tasks.
- Session
Id - Opaque LiveView session identifier.
- Session
Replay Metadata - Capture metadata describing one replayable session trace.
- Session
Replay Trace - Serializable replay artifact.
- Session
Replay Trace Step - One deterministic turn in a replay trace.
- Session
Trace Recorder - In-memory recorder for building replay artifacts from live session turns.
- Telemetry
Event - Template
- A rendered template split into static and dynamic segments.
- Template
Snapshot - Render metadata retained from a segmented template.
- Time
Travel Frame - Time
Travel Inspector - Toast
- One toast message shown by the browser runtime.
- Trace
Redaction Policy - Redaction policy for trace capture and report sharing.
- Trace
Redaction Summary - Capture-time redaction summary embedded into trace artifacts.
- Validation
Errors - Path-keyed validation error bag for nested forms.
Enums§
- Client
Message - Message received from the browser runtime.
- Grid
Pinned - Grid column pin side.
- Grid
Sort Direction - Grid sort direction.
- Nested
Live View State - Runtime lifecycle state for one nested LiveView.
- Protocol
Authority - Protocol
Direction - Protocol
Durability - Protocol
Instruction Class - Protocol
Ordering - Protocol
Render Effect - PubSub
Command - Internal commands collected from
Contextand executed by the adapter. - PubSub
Delivery Scope - Delivery topology for one PubSub backend.
- PubSub
Ordering - Ordering contract for one PubSub backend.
- PubSub
Receive Error - Errors produced while receiving subscription fanout.
- Replay
Step Status - Resume
Status - Resume handshake outcome communicated in
hello. - Runtime
Command - Internal runtime commands collected from
Contextand executed by the adapter. - Server
Message - Message sent from the Rust runtime to the browser runtime.
- Session
Affinity Requirement - Session-affinity contract for one PubSub backend.
- Shelly
Error - Errors returned by the Shelly core runtime.
- Stream
Batch Operation - One stream operation used by
stream_batch. - Stream
Position - Position used by a
stream_insertserver message. - Telemetry
Event Kind - Toast
Level - Visual severity for a toast.
Constants§
- INTERNAL_
RENDER_ FLUSH_ EVENT - PROTOCOL_
VERSION_ V1 - REPLAY_
TRACE_ FORMAT_ VERSION - SUPPORTED_
PROTOCOL_ VERSIONS
Traits§
- Live
Component - Trait implemented by server-owned child components.
- Live
View - Trait implemented by server-owned interactive views.
- PubSub
Backend - Backend interface for adapter-executed PubSub commands.
- Telemetry
Sink
Functions§
- describe_
client_ message - describe_
server_ message - dot_
path - Normalize bracket/dot path notation into dotted notation.
- escape_
html - Escape text for inclusion in HTML text or attribute values.
- is_
supported_ protocol_ version - parse_
path_ segments - Parse bracket or dot paths into normalized path segments.
- replay_
trace - Replay one trace with a fresh session built from
view_factory. - validate_
client_ message_ invariants - validate_
server_ message_ invariants - validate_
server_ message_ sequence - value_
as_ string - Shared helper for reading optional JSON string values.
Type Aliases§
- Live
Result - Convenient result type used by the Shelly runtime.