Skip to main content

Crate shelly

Crate shelly 

Source
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§

ChartAnnotation
One chart annotation marker.
ChartPoint
One numeric chart point.
ComponentId
Stable server-owned identifier for a LiveComponent.
ComponentRender
Render result for one component after a scoped event.
Context
Mutable context passed into LiveView lifecycle callbacks.
DynamicSlotPatch
Dynamic slot update sent by a diff server message.
Event
A normalized browser event delivered to a LiveView.
FormData
Path-aware reader for nested form payloads.
GridColumn
One grid column descriptor.
GridRow
One grid row record.
GridRowsWindow
Active window rows for one grid snapshot.
GridSavedView
One saved grid view.
GridSort
Active grid sort definition.
GridState
Full browser-managed data-grid state.
Html
A server-rendered HTML fragment.
InboxItem
One inbox item shown by the browser runtime.
JsInteropDispatch
One browser interop dispatch instruction.
LiveSession
Runtime holder for one connected LiveView instance.
MemoryTelemetrySink
NestedLiveViewId
Stable server-owned identifier for a nested LiveView instance.
NestedLiveViewSnapshot
Public snapshot of one nested LiveView runtime boundary.
NoopTelemetrySink
ProtocolInstructionDescriptor
ProtocolInvariantViolation
PubSub
Adapter-owned PubSub runtime abstraction.
PubSubCapabilities
Cluster capabilities advertised by a PubSub backend.
PubSubMessage
Message delivered by one PubSub backend.
PubSubPresenceSnapshot
Presence snapshot for one topic across nodes.
PubSubSubscription
Live subscription receiver for one topic.
ReplayReport
ReplayStepResult
RuntimeEvent
Structured event payload emitted by adapter-managed runtime tasks.
SessionId
Opaque LiveView session identifier.
SessionReplayMetadata
Capture metadata describing one replayable session trace.
SessionReplayTrace
Serializable replay artifact.
SessionReplayTraceStep
One deterministic turn in a replay trace.
SessionTraceRecorder
In-memory recorder for building replay artifacts from live session turns.
TelemetryEvent
Template
A rendered template split into static and dynamic segments.
TemplateSnapshot
Render metadata retained from a segmented template.
TimeTravelFrame
TimeTravelInspector
Toast
One toast message shown by the browser runtime.
TraceRedactionPolicy
Redaction policy for trace capture and report sharing.
TraceRedactionSummary
Capture-time redaction summary embedded into trace artifacts.
ValidationErrors
Path-keyed validation error bag for nested forms.

Enums§

ClientMessage
Message received from the browser runtime.
GridPinned
Grid column pin side.
GridSortDirection
Grid sort direction.
NestedLiveViewState
Runtime lifecycle state for one nested LiveView.
ProtocolAuthority
ProtocolDirection
ProtocolDurability
ProtocolInstructionClass
ProtocolOrdering
ProtocolRenderEffect
PubSubCommand
Internal commands collected from Context and executed by the adapter.
PubSubDeliveryScope
Delivery topology for one PubSub backend.
PubSubOrdering
Ordering contract for one PubSub backend.
PubSubReceiveError
Errors produced while receiving subscription fanout.
ReplayStepStatus
ResumeStatus
Resume handshake outcome communicated in hello.
RuntimeCommand
Internal runtime commands collected from Context and executed by the adapter.
ServerMessage
Message sent from the Rust runtime to the browser runtime.
SessionAffinityRequirement
Session-affinity contract for one PubSub backend.
ShellyError
Errors returned by the Shelly core runtime.
StreamBatchOperation
One stream operation used by stream_batch.
StreamPosition
Position used by a stream_insert server message.
TelemetryEventKind
ToastLevel
Visual severity for a toast.

Constants§

INTERNAL_RENDER_FLUSH_EVENT
PROTOCOL_VERSION_V1
REPLAY_TRACE_FORMAT_VERSION
SUPPORTED_PROTOCOL_VERSIONS

Traits§

LiveComponent
Trait implemented by server-owned child components.
LiveView
Trait implemented by server-owned interactive views.
PubSubBackend
Backend interface for adapter-executed PubSub commands.
TelemetrySink

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§

LiveResult
Convenient result type used by the Shelly runtime.