bsdkrun/types

Typed records mirroring bsdkrun’s --json output, their decoders, and the result of running a command inside a guest.

Types

The captured result of running a command in a guest.

pub type CommandResult {
  CommandResult(
    stdout: String,
    stderr: String,
    exit_code: Int,
    command: String,
  )
}

Constructors

  • CommandResult(
      stdout: String,
      stderr: String,
      exit_code: Int,
      command: String,
    )

An image, as reported by bsdkrun images --json.

pub type ImageInfo {
  ImageInfo(
    id: String,
    reference: String,
    digest: String,
    size: Int,
    rootfs: String,
    created_at: Int,
  )
}

Constructors

  • ImageInfo(
      id: String,
      reference: String,
      digest: String,
      size: Int,
      rootfs: String,
      created_at: Int,
    )

A global network, as reported by bsdkrun network ls --json.

pub type NetworkInfo {
  NetworkInfo(
    name: String,
    subnet: String,
    gateway: String,
    members: Int,
    running: Int,
    up: Bool,
    created_at: option.Option(Int),
  )
}

Constructors

  • NetworkInfo(
      name: String,
      subnet: String,
      gateway: String,
      members: Int,
      running: Int,
      up: Bool,
      created_at: option.Option(Int),
    )

A machine, as reported by bsdkrun ps --json.

pub type SandboxInfo {
  SandboxInfo(
    id: String,
    name: option.Option(String),
    image: String,
    kind: String,
    command: String,
    running: Bool,
    exit_code: option.Option(Int),
    pid: option.Option(Int),
    detached: Bool,
    cpus: Int,
    mem: Int,
    volume: option.Option(String),
    state_dir: String,
    network: option.Option(String),
    net_ip: option.Option(String),
    created_at: Int,
    finished_at: option.Option(Int),
  )
}

Constructors

A persistent volume, as reported by bsdkrun volume ls --json.

pub type VolumeInfo {
  VolumeInfo(
    name: String,
    guest: option.Option(String),
    base: option.Option(String),
    path: String,
    size: String,
    created_at: option.Option(Int),
    tracked: Bool,
  )
}

Constructors

Values

pub fn decode_rows(
  raw: String,
  label: String,
  row: decode.Decoder(a),
) -> Result(List(a), error.Error)

Decode a --json list payload. Blank output — which the CLI emits when there is nothing to list — decodes as the empty list.

pub fn image_info_decoder() -> decode.Decoder(ImageInfo)

Decoder for one images --json row.

pub fn is_ok(res: CommandResult) -> Bool

Whether the command succeeded (exit 0).

pub fn lines(res: CommandResult) -> List(String)

Non-empty stdout lines.

pub fn network_info_decoder() -> decode.Decoder(NetworkInfo)

Decoder for one network ls --json row.

pub fn sandbox_info_decoder() -> decode.Decoder(SandboxInfo)

Decoder for one ps --json row.

pub fn status(info: SandboxInfo) -> String

"running" or "exited" — the status column bsdkrun ps prints.

pub fn text(res: CommandResult) -> String

stdout with trailing newlines trimmed — the common case.

pub fn volume_info_decoder() -> decode.Decoder(VolumeInfo)

Decoder for one volume ls --json row.

Search Document