Help us shape the future of Go! Take the 2026 Go Developer Survey

msgpack

package
v0.57.13 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockToObject

func BlockToObject[T comparable](ctx context.Context, bcs *block.Cursor, dest T) (T, error)

BlockToObject converts the given block cursor into an object. T and dest can be a nil interface{} to unmarshal a dynamic type. if bcs is nil returns dest, nil

func NewMsgpackBlobBlock

func NewMsgpackBlobBlock() block.Block

NewMsgpackBlobBlock constructs a new db root block.

func ObjectToBlock

func ObjectToBlock[T any](bcs *block.Cursor, obj T) error

ObjectToBlock converts a given object into a msgpack block at bcs.

Types

type MsgpackBlob

type MsgpackBlob struct {

	// Blob contains the encoded data in a blob.
	//
	// If small enough, the blob will be stored in-line.
	Blob *blob.Blob `protobuf:"bytes,1,opt,name=blob,proto3" json:"blob,omitempty"`
	// contains filtered or unexported fields
}

MsgpackBlob is a block containing data packed with msgpack.

API: BuildMsgpackBlob(object interface{}) -> pack into MsgpackBlob. Decode: blob.UnmarshalMsgpack() -> object interface{}

func BuildMsgpackBlob

func BuildMsgpackBlob(
	ctx context.Context,
	bcs *block.Cursor,
	opts *blob.BuildBlobOpts,
	obj any,
) (*MsgpackBlob, error)

BuildMsgpackBlob packs an object into a blob, storing the object into the cursor.

opts can be nil

func UnmarshalMsgpackBlob

func UnmarshalMsgpackBlob(ctx context.Context, bcs *block.Cursor) (*MsgpackBlob, error)

UnmarshalMsgpackBlob loads a msgpack blob at a cursor. may return nil

func (*MsgpackBlob) ApplySubBlock

func (m *MsgpackBlob) ApplySubBlock(id uint32, next block.SubBlock) error

ApplySubBlock applies a sub-block change with a field id.

func (*MsgpackBlob) BlockAliasIdentity added in v0.52.0

func (m *MsgpackBlob) BlockAliasIdentity() *block.AliasIdentityToken

BlockAliasIdentity returns the in-memory alias token for MsgpackBlob.

func (*MsgpackBlob) BuildMsgpackDecoder

func (m *MsgpackBlob) BuildMsgpackDecoder(ctx context.Context, bcs *block.Cursor) (*msgpack.Decoder, error)

BuildMsgpackDecoder builds a streaming decoder for the blob.

bcs must be located at the MsgpackBlob object.

func (*MsgpackBlob) CloneMessageVT

func (m *MsgpackBlob) CloneMessageVT() protobuf_go_lite.CloneMessage

func (*MsgpackBlob) CloneVT

func (m *MsgpackBlob) CloneVT() *MsgpackBlob

func (*MsgpackBlob) EqualMessageVT

func (this *MsgpackBlob) EqualMessageVT(thatMsg any) bool

func (*MsgpackBlob) EqualVT

func (this *MsgpackBlob) EqualVT(that *MsgpackBlob) bool

func (*MsgpackBlob) GetBlob

func (x *MsgpackBlob) GetBlob() *blob.Blob

func (*MsgpackBlob) GetSubBlockCtor

func (m *MsgpackBlob) GetSubBlockCtor(id uint32) block.SubBlockCtor

GetSubBlockCtor returns a function which creates or returns the existing sub-block at reference id. Can return nil to indicate invalid reference id.

func (*MsgpackBlob) GetSubBlocks

func (m *MsgpackBlob) GetSubBlocks() map[uint32]block.SubBlock

GetSubBlocks returns all constructed sub-blocks by ID. May return nil, and values may also be nil.

func (*MsgpackBlob) IsEmpty

func (m *MsgpackBlob) IsEmpty() bool

IsEmpty checks if the blob is empty.

func (*MsgpackBlob) IsNil

func (m *MsgpackBlob) IsNil() bool

IsNil returns if the object is nil.

func (*MsgpackBlob) MarshalBlock

func (m *MsgpackBlob) MarshalBlock() ([]byte, error)

MarshalBlock marshals the block to binary. This is the initial step of marshaling, before transformations.

func (*MsgpackBlob) MarshalJSON

func (x *MsgpackBlob) MarshalJSON() ([]byte, error)

MarshalJSON marshals the MsgpackBlob to JSON.

func (*MsgpackBlob) MarshalProtoJSON

func (x *MsgpackBlob) MarshalProtoJSON(s *json.MarshalState)

MarshalProtoJSON marshals the MsgpackBlob message to JSON.

func (*MsgpackBlob) MarshalProtoText

func (x *MsgpackBlob) MarshalProtoText() string

func (*MsgpackBlob) MarshalToSizedBufferVT

func (m *MsgpackBlob) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*MsgpackBlob) MarshalToVT

func (m *MsgpackBlob) MarshalToVT(dAtA []byte) (int, error)

func (*MsgpackBlob) MarshalVT

func (m *MsgpackBlob) MarshalVT() (dAtA []byte, err error)

func (*MsgpackBlob) ProtoMessage

func (*MsgpackBlob) ProtoMessage()

func (*MsgpackBlob) Reset

func (x *MsgpackBlob) Reset()

func (*MsgpackBlob) SizeVT

func (m *MsgpackBlob) SizeVT() (n int)

func (*MsgpackBlob) String

func (x *MsgpackBlob) String() string

func (*MsgpackBlob) UnmarshalBlock

func (m *MsgpackBlob) UnmarshalBlock(data []byte) error

UnmarshalBlock unmarshals the block to the object. This is the final step of decoding, after transformations.

func (*MsgpackBlob) UnmarshalJSON

func (x *MsgpackBlob) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the MsgpackBlob from JSON.

func (*MsgpackBlob) UnmarshalMsgpack

func (m *MsgpackBlob) UnmarshalMsgpack(ctx context.Context, bcs *block.Cursor, obj any) error

UnmarshalMsgpack unmarshals the msgpack data to an object.

bcs must be located at the MsgpackBlob object.

func (*MsgpackBlob) UnmarshalProtoJSON

func (x *MsgpackBlob) UnmarshalProtoJSON(s *json.UnmarshalState)

UnmarshalProtoJSON unmarshals the MsgpackBlob message from JSON.

func (*MsgpackBlob) UnmarshalVT

func (m *MsgpackBlob) UnmarshalVT(dAtA []byte) error

func (*MsgpackBlob) Validate

func (m *MsgpackBlob) Validate() error

Validate performs cursory validation of the msgpack blob.

type MsgpackBlock

type MsgpackBlock[T any] struct {
	// contains filtered or unexported fields
}

MsgpackBlock directly wraps an interface with a decoder/encoder.

func NewMsgpackBlock

func NewMsgpackBlock[T any](obj T) *MsgpackBlock[T]

NewMsgpackBlock builds a new object wrapped with a msgpack decoder.

Obj should be a pointer to the field to decode / encode.

func UnmarshalMsgpackBlock

func UnmarshalMsgpackBlock[T any](ctx context.Context, bcs *block.Cursor, ctor func() T) (*MsgpackBlock[T], error)

UnmarshalMsgpackBlock loads a msgpack block at a cursor. if ctor is nil, uses the empty value of T. may return nil

func (*MsgpackBlock[T]) BlockAliasIdentity added in v0.52.0

func (b *MsgpackBlock[T]) BlockAliasIdentity() *block.AliasIdentityToken

BlockAliasIdentity returns the in-memory alias token for MsgpackBlock.

func (*MsgpackBlock[T]) GetObj

func (b *MsgpackBlock[T]) GetObj() T

GetObj returns the contained object.

func (*MsgpackBlock[T]) IsNil

func (b *MsgpackBlock[T]) IsNil() bool

IsNil checks if the object is nil.

func (*MsgpackBlock[T]) MarshalBlock

func (b *MsgpackBlock[T]) MarshalBlock() ([]byte, error)

MarshalBlock marshals the block to binary. This is the initial step of marshaling, before transformations.

func (*MsgpackBlock[T]) SetObj

func (b *MsgpackBlock[T]) SetObj(obj T)

SetObj sets the contained object.

func (*MsgpackBlock[T]) UnmarshalBlock

func (b *MsgpackBlock[T]) UnmarshalBlock(data []byte) error

UnmarshalBlock unmarshals the block to the object. This is the final step of decoding, after transformations.

Jump to

Keyboard shortcuts

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