plushie/stdio

Run a plushie application in stdio transport mode.

In stdio mode, the Rust renderer spawns the Gleam process (not the other way around) and communicates over stdin/stdout. This is the inverse of gui.run where Gleam spawns the renderer. All log output goes to stderr to avoid corrupting the wire protocol on stdout.

Use stdio mode when embedding plushie in a larger application that manages the renderer lifecycle externally.

import plushie/stdio

pub fn main() {
  stdio.run(my_app.app(), stdio.default_opts())
}

Types

Options for stdio mode.

pub type StdioOpts {
  StdioOpts(format: protocol.Format, daemon: Bool)
}

Constructors

  • StdioOpts(format: protocol.Format, daemon: Bool)

    Arguments

    format

    Wire format. Default: MessagePack.

    daemon

    Keep running after all windows close. Default: False.

Values

pub fn default_opts() -> StdioOpts

Default stdio options.

pub fn run(
  app: app.App(model, event.Event),
  opts: StdioOpts,
) -> Nil

Run a plushie application in stdio transport mode.

Starts the runtime with stdio transport and blocks until the process exits (typically on stdin EOF).

Search Document