object

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package object provides functionalities for handling different types of Massa objects. It supports encoding and decoding operations with appropriate prefixes and versioning.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedVersion = errors.New("unsupported version")
	ErrEmptyType          = errors.New("empty type")
	ErrInvalidType        = errors.New("invalid type")
)

Functions

This section is empty.

Types

type Kind

type Kind int

Kind represents the type of data being manipulated.

const (
	Unknown Kind = iota
	EncryptedPrivateKey
	PublicKey
	UserAddress
	SmartContractAddress
)

func NewKind

func NewKind(data string) Kind

NewKind determines the kind of data based on its prefix.

func (Kind) Prefix

func (k Kind) Prefix() string

Prefix returns the prefix corresponding to the kind of data.

type Object

type Object struct {
	Data    []byte
	Kind    Kind
	Version byte
}

Object represents a Massa object with its data, kind, and version.

func (*Object) MarshalBinary

func (o *Object) MarshalBinary() ([]byte, error)

MarshalBinary implements the encoding.BinaryMarshaler interface.

func (*Object) MarshalText

func (o *Object) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*Object) MustBytes

func (o *Object) MustBytes() []byte

MustBytes returns the binary representation of the object.

func (*Object) UnmarshalBinary

func (o *Object) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

func (*Object) UnmarshalText

func (o *Object) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (*Object) Validate

func (o *Object) Validate(lastVersion byte, expectedKinds ...Kind) error

Validate ensures the Object.Kind is one of the expected types and the version is supported.

Jump to

Keyboard shortcuts

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