plushie/protocol/decode

Decode inbound wire messages into typed Gleam values.

Supports both MessagePack and JSON wire formats. The Rust binary sends three top-level message types: “hello” (handshake), “event” (user interaction dispatched by family), and “effect_response” (platform result). Additionally, “op_query_response” messages carry system query results.

Types

A decoded inbound message from the Rust binary.

pub type InboundMessage {
  Hello(
    protocol: Int,
    version: String,
    name: String,
    backend: String,
    extensions: List(String),
    transport: String,
  )
  EventMessage(event.Event)
}

Constructors

  • Hello(
      protocol: Int,
      version: String,
      name: String,
      backend: String,
      extensions: List(String),
      transport: String,
    )

    Handshake sent by the Rust binary on startup.

  • EventMessage(event.Event)

    A user interaction or system event.

Values

pub fn decode_message(
  data: BitArray,
  format: protocol.Format,
) -> Result(InboundMessage, protocol.DecodeError)

Decode raw wire bytes into an InboundMessage.

pub fn split_scoped_id(
  wire_id: String,
) -> #(String, List(String))

Split a scoped wire ID into (local_id, scope_list).

Named containers scope their children with “/” separators. The scope list is reversed so the nearest container is first.

split_scoped_id("form/email")
// -> #("email", ["form"])

split_scoped_id("sidebar/form/email")
// -> #("email", ["form", "sidebar"])

split_scoped_id("button")
// -> #("button", [])
Search Document