structfield

package
v0.19.0-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package structfield provides types to track struct field offsets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ID

type ID struct {
	// ModPath is the module path containing the struct field package.
	//
	// If set to "std", the struct field belongs to the standard Go library.
	ModPath string
	// PkgPath package import path containing the struct field.
	PkgPath string
	// Struct is the name of the struct containing the field.
	Struct string
	// Field is the field name.
	Field string
}

ID is a struct field identifier for an offset.

func NewID

func NewID(mod, pkg, strct, field string) ID

NewID returns a new ID using pkg for the PkgPath, strct for the Struct, and field for the Field.

func (ID) String

func (i ID) String() string

type Index

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

Index holds all struct field offsets.

func NewIndex

func NewIndex() *Index

NewIndex returns a new empty Index.

func (*Index) Get

func (i *Index) Get(id ID) (*Offsets, bool)

Get returns the Offsets and true for an id contained in the Index i. It will return nil and false for any id not contained in i.

func (*Index) GetLatestOffset

func (i *Index) GetLatestOffset(id ID) (OffsetKey, *version.Version)

GetLatestOffset returns the latest known offset value and version for id contained in the Index i.

func (*Index) GetOffset

func (i *Index) GetOffset(id ID, ver *version.Version) (OffsetKey, bool)

GetOffset returns the offset value and true for the version ver of id contained in the Index i. It will return zero and false for any id not contained in i.

func (*Index) MarshalJSON

func (i *Index) MarshalJSON() ([]byte, error)

MarshalJSON marshals i into JSON data.

func (*Index) Put

func (i *Index) Put(id ID, offsets *Offsets)

Put stores offsets in the Index i for id.

Any existing offsets stored for id will be replaced. Use PutOffset if you would like to update existing offsets for id with an offset value.

func (*Index) PutOffset

func (i *Index) PutOffset(id ID, ver *version.Version, offset uint64, valid bool)

PutOffset stores the offset value for version ver of id within the Index i.

This will update any existing offsets stored for id with offset. If ver already exists within those offsets it will overwrite that value.

func (*Index) UnmarshalJSON

func (i *Index) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the offset JSON data into i.

type OffsetKey

type OffsetKey struct {
	Offset uint64
	Valid  bool
}

OffsetKey is the offset of a specific struct field in a specific version. If Valid is false, the offset is not known for the struct field at the specified version.

type Offsets

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

Offsets are the byte offsets for a struct field at specific versions of the package containing struct.

func NewOffsets

func NewOffsets() *Offsets

NewOffsets returns a new empty *Offsets.

func (*Offsets) Get

func (o *Offsets) Get(ver *version.Version) (OffsetKey, bool)

Get returns the offset in bytes and true if known. Otherwise, 0 and false are returned.

func (*Offsets) Put

func (o *Offsets) Put(ver *version.Version, offset OffsetKey)

Put sets the offset value for ver. If an offset for ver is already known (i.e. ver.Equal(other) == true), this will overwrite that value.

Jump to

Keyboard shortcuts

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