frame

package
v0.0.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package frame is the dev-mode wire between the device proxy, the relay in `nimbus native dev` and the app process on the laptop: typed, length-prefixed frames over TCP.

Index

Constants

View Source
const (
	RoleDevice byte = 1
	RoleApp    byte = 2
)

Roles in a Hello frame.

Variables

This section is empty.

Functions

func HelloPayload

func HelloPayload(role byte, schema, session uint64) []byte

HelloPayload is a Hello frame's payload. session is the dev session a dev shell was built for (0 for an app process), so the relay can tell this session's shell from one another session left open on the device.

func ParseHello

func ParseHello(p []byte) (role byte, schema, session uint64, ok bool)

ParseHello reads a Hello payload (a shell from before sessions sends none).

func Reply

func Reply(id uint32, rc byte, b []byte) []byte

Reply is a call or host-call reply: id, result code (nn.h), bytes.

func SplitID

func SplitID(p []byte) (uint32, []byte, bool)

SplitID splits an id-prefixed payload.

func SplitReply

func SplitReply(p []byte) (id uint32, rc byte, b []byte, ok bool)

SplitReply splits a reply payload.

func WithID

func WithID(id uint32, b []byte) []byte

WithID prefixes a call or host call with its id.

func Write

func Write(w io.Writer, t Type, payload []byte) error

Write sends one frame. Callers serialise writes to a connection.

Types

type Type

type Type uint8

Type says what a frame carries.

const (
	Hello     Type = 1 // role byte + schema hash (u64 LE): who connected
	ToGo      Type = 2 // host → Go async message (device → app)
	FromGo    Type = 3 // Go → host async message (app → device)
	Call      Type = 4 // host → Go sync call: id u32 + request
	CallReply Type = 5 // id u32 + rc u8 + reply
	HostCall  Type = 6 // Go → host sync call: id u32 + request
	HostReply Type = 7 // id u32 + rc u8 + reply
	Reset     Type = 8 // relay → device: a new app process is taking over
)

func Read

func Read(r io.Reader) (Type, []byte, error)

Read receives one frame.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL