Skip to main content

Crate st_protocol

Crate st_protocol 

Source
Expand description

ST Protocol - Binary Wire Protocol for Smart Tree Daemon

A tight, 6502-inspired binary protocol using control ASCII (0x00-0x1F) as opcodes. No JSON in the core path. Every byte means something.

§Frame Format

┌──────┬─────────────────┬──────┐
│ verb │     payload     │ 0x00 │
│ 1B   │   N bytes       │ END  │
└──────┴─────────────────┴──────┘

§Escape Sequences

  • 0x1B 0x1B = literal 0x1B in payload
  • 0x1B 0x00 = literal 0x00 in payload

§Network Addressing

Single byte prefix for routing:

  • 0x00 = local daemon (Unix socket)
  • 0x01-0x7F = cached host index
  • 0x80-0xFE = inline address (len = byte - 0x80)
  • 0xFF = broadcast/discover

Structs§

AddressString
Inline address string (max 126 bytes)
AuthBlock
Authentication block parsed from wire format
Frame
A complete protocol frame
FrameBuilder
Builder for constructing frames
HostCache
Host cache for remembered remote daemons
Payload
Raw payload data with escape handling
PayloadDecoder
Payload decoder for parsing complex payloads
PayloadEncoder
Payload encoder for building complex payloads
SecurityContext
Security context for a connection
SessionId
Session UUID (16 bytes)
Signature
Ed25519 signature (32 bytes)

Enums§

Address
Network address for daemon communication
AuthLevel
Authentication level required for operations
ProtocolError
Protocol-specific errors
Verb
Protocol verbs mapped to control ASCII codes

Constants§

END
End of frame marker
ESC
Escape byte
MAX_FRAME_SIZE
Maximum frame size including overhead
MAX_PAYLOAD_LEN
Maximum payload length (64KB)
PROTECTED_PATHS
Protected paths that require elevation
VERSION
Protocol version

Functions§

is_protected_path
Check if a path requires elevated access
path_auth_level
Get required auth level for a path

Type Aliases§

ProtocolResult
Result type for protocol operations