artifact

package
v2.0.0-alpha.9 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidArtifact reports a loader or artifact state error not covered by
	// a more specific sentinel.
	ErrInvalidArtifact = errors.New("bytecode artifact: invalid artifact")
	// ErrInvalidHeader reports that the artifact header is malformed or
	// inconsistent with the payload framing.
	ErrInvalidHeader = errors.New("bytecode artifact: invalid header")
	// ErrInvalidPayload reports that the selected payload format could not decode
	// the serialized program.
	ErrInvalidPayload = errors.New("bytecode artifact: invalid payload")
	// ErrInvalidMagic reports that the artifact header does not start with the
	// Ferret artifact magic bytes.
	ErrInvalidMagic = errors.New("bytecode artifact: invalid magic")
	// ErrUnsupportedSchema reports that the artifact schema version is not
	// understood by the current loader.
	ErrUnsupportedSchema = errors.New("bytecode artifact: unsupported schema version")
	// ErrUnknownFormat reports that an artifact references an unknown or
	// unregistered payload format.
	ErrUnknownFormat = errors.New("bytecode artifact: unknown format")
	// ErrIncompatibleISA reports that an artifact or payload requires a different
	// bytecode ISA version than the current runtime.
	ErrIncompatibleISA = errors.New("bytecode artifact: incompatible ISA")
)

Functions

func HasMagic

func HasMagic(data []byte) bool

HasMagic reports whether data begins with the Ferret artifact magic bytes. It is intended for sniffing likely Ferret artifacts only. A true result does not guarantee that data is complete, valid, loadable, or compatible; callers that need actual artifact validation must still use Load or Unmarshal.

func Marshal

func Marshal(program *bytecode.Program, opts Options) ([]byte, error)

Marshal serializes a program into a self-describing artifact using one of the built-in payload formats.

func Unmarshal

func Unmarshal(data []byte) (*bytecode.Program, error)

Unmarshal decodes a self-describing artifact using the built-in loader.

Types

type FormatID

type FormatID uint8

FormatID identifies a serialized program payload format in an artifact header.

const (
	FormatJSON    FormatID = 1
	FormatMsgPack FormatID = 2
	DefaultFormat          = FormatMsgPack
)

type Loader

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

func NewDefaultLoader

func NewDefaultLoader() *Loader

NewDefaultLoader creates a loader with the built-in artifact payload formats.

func NewLoader

func NewLoader(formats ...RegisteredFormat) *Loader

NewLoader creates an artifact loader with an explicit set of registered payload formats. Nil or duplicate registrations panic.

func (*Loader) Load

func (l *Loader) Load(data []byte) (*bytecode.Program, error)

Load decodes a self-describing bytecode artifact and validates header, schema, ISA, and payload compatibility before returning a program.

type Options

type Options struct {
	Format FormatID
}

Options controls artifact marshaling.

type RegisteredFormat

type RegisteredFormat struct {
	Format programformat.Format
	ID     FormatID
}

RegisteredFormat associates an artifact format id with a payload format implementation.

Jump to

Keyboard shortcuts

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