update

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package update defines the versioned HTML update contract shared by USB, the home manager, and the encrypted device link.

Index

Constants

View Source
const (
	HeaderSize     = 160
	TrailerSize    = 4
	MaxEncodedSize = HeaderSize + document.MaxEncodedBytes + TrailerSize
)
View Source
const (
	Version           = 1
	DisplayTimeLength = 16
	MaxTimezoneLength = 64
)
View Source
const ResultEncodedSize = 104

Variables

View Source
var (
	ErrBuffer = errors.New("update: output buffer too small")
	ErrCodec  = errors.New("update: invalid encoded request")
)
View Source
var (
	ErrID       = errors.New("update: invalid id")
	ErrTime     = errors.New("update: invalid time")
	ErrTimezone = errors.New("update: invalid timezone")
)
View Source
var (
	ErrRejected = errors.New("update: rejected")
	ErrResult   = errors.New("update: invalid result")
)

Functions

func Encode

func Encode(destination []byte, request Request) (int, error)

func EncodeResult

func EncodeResult(destination []byte, result Result) (int, error)

func EncodedSize

func EncodedSize(request Request) int

func EncodedSizeFromHeader

func EncodedSizeFromHeader(header []byte) (int, error)

EncodedSizeFromHeader returns the complete record size after the fixed header is available. Integrity and semantic validation still happen in Decode.

Types

type Code

type Code uint8
const (
	CodeInvalid Code = 1 + iota
	CodeUnsupported
	CodeLimit
	CodeConflict
	CodeCancelled
	CodeStalled
	CodeUnavailable
	CodeInternal
)

func (Code) String

func (c Code) String() string

type Diagnostic

type Diagnostic struct {
	Stage    Stage
	Code     Code
	Limit    string
	Observed int
	Maximum  int
	Node     uint16
}

func (Diagnostic) Validate

func (d Diagnostic) Validate() error

type Digest

type Digest [sha256.Size]byte

type Error

type Error struct {
	Diagnostic Diagnostic
	Cause      error
}

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(target error) bool

func (*Error) Unwrap

func (e *Error) Unwrap() error

type ID

type ID [16]byte

type Request

type Request struct {
	// contains filtered or unexported fields
}

func Decode

func Decode(wire []byte) (Request, error)

func NewRequest

func NewRequest(id ID, utc int64, displayTime, timezone string, source document.Source) (Request, error)

func (Request) ContentHash

func (r Request) ContentHash() Digest

func (Request) DisplayTime

func (r Request) DisplayTime() string

func (Request) DisplayTimeBytes

func (r Request) DisplayTimeBytes() [DisplayTimeLength]byte

func (Request) Document

func (r Request) Document() document.Source

func (Request) ID

func (r Request) ID() ID

func (Request) SameIntent

func (r Request) SameIntent(other Request) bool

func (Request) Timezone

func (r Request) Timezone() string

func (Request) UTC

func (r Request) UTC() int64

func (Request) Validate

func (r Request) Validate() error

type Result

type Result struct {
	ID          ID
	Status      Status
	ContentHash Digest
	Diagnostic  Diagnostic
}

func DecodeResult

func DecodeResult(wire []byte) (Result, error)

func (Result) Validate

func (r Result) Validate() error

type Stage

type Stage uint8
const (
	StageReceive Stage = 1 + iota
	StageAuthenticate
	StageDecode
	StageParse
	StageStyle
	StageLayout
	StageRaster
	StageRefresh
)

func (Stage) String

func (s Stage) String() string

type Status

type Status uint8
const (
	StatusAccepted Status = 1 + iota
	StatusUnchanged
	StatusRefreshed
	StatusRejected
)

Jump to

Keyboard shortcuts

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