resuma 0.4.6

Resuma - SSR + Resumability + Islands + Server Actions + JS Bridge for Rust
Documentation
//! Handler & action descriptors that travel from server to client.

use serde::{Deserialize, Serialize};

use super::signal::SignalId;

/// A signal captured by an event handler closure. Carries both the Rust
/// identifier (`name`) used to access it from the translated JS body and
/// the stable `SignalId` allocated by the SSR pass.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HandlerCapture {
    pub name: String,
    pub id: SignalId,
}

/// Reference to an event handler whose body lives in a lazy-loaded JS chunk.
///
/// Generated by the `view!` macro: it inspects the handler closure, asks the
/// `resuma-rs2js` crate to translate it to a JS expression, and stores the
/// resulting chunk id + symbol here.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HandlerRef {
    /// DOM event name without the `on` prefix (e.g. `click`, `input`).
    pub event: String,
    /// JS chunk id (resolved to `/_resuma/handler/<chunk>.js` at runtime).
    pub chunk: String,
    /// Symbol within the chunk.
    pub symbol: String,
    /// Signals captured by the handler. The runtime turns these into a
    /// `state` proxy keyed by the Rust identifier.
    pub captures: Vec<HandlerCapture>,
    /// Inline JS source (pre-built). When present the runtime may evaluate
    /// the handler immediately without a network round-trip — used for tiny
    /// handlers like `count.update(|c| c + 1)`.
    pub inline: Option<String>,
}

/// Reference to a `#[server]` action exposed at `/_resuma/action/<name>`.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ServerActionRef {
    pub name: String,
}

/// Reference to an `#[island]` chunk.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IslandRef {
    pub chunk_id: String,
    pub instance_id: String,
}