object

package
v0.53.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const MaxHeaderVarintLen = 3

MaxHeaderVarintLen is varint len of object.MaxHeaderLen.

View Source
const NonPayloadFieldsBufferLength = 20 << 10

NonPayloadFieldsBufferLength is a length of the buffer sufficient to read an object of maximum size without taking into account the payload. Its value is a multiple of 4K.

Variables

View Source
var ErrAttributeNotFound = errors.New("attribute not found")

ErrAttributeNotFound is returned when some object attribute not found.

Functions

func ExtractHeaderAndPayload

func ExtractHeaderAndPayload(data []byte) (*object.Object, []byte, error)

ExtractHeaderAndPayload extracts the header of an object from the given byte slice and also returns payload prefix.

func GetAttribute

func GetAttribute(hdr object.Object, attr string) string

GetAttribute looks up for specified attribute in the given object header. Returns empty string if the attribute is missing.

GetIntAttribute ignores all attribute values except the first.

func GetIndexAttribute

func GetIndexAttribute(hdr object.Object, attr string) (int, error)

GetIndexAttribute looks up for specified index attribute in the given object header. Returns -1 if the attribute is missing.

GetIndexAttribute ignores all attribute values except the first.

Note that if attribute exists but negative, GetIndexAttribute returns error.

func GetIntAttribute

func GetIntAttribute(hdr object.Object, attr string) (int, error)

GetIntAttribute looks up for specified int attribute in the given object header. Returns ErrAttributeNotFound if the attribute is missing.

GetIntAttribute ignores all attribute values except the first.

func GetNonPayloadFieldBounds added in v0.52.0

func GetNonPayloadFieldBounds(buf []byte) (iprotobuf.FieldBounds, iprotobuf.FieldBounds, iprotobuf.FieldBounds, error)

GetNonPayloadFieldBounds seeks ID, signature and header in object message and parses their boundaries.

If buf is empty, GetNonPayloadFieldBounds returns an error.

If any field is missing, no error is returned.

Message should have ascending field order, otherwise error returns.

func GetParentNonPayloadFieldBounds added in v0.52.0

func GetParentNonPayloadFieldBounds(buf []byte) (iprotobuf.FieldBounds, iprotobuf.FieldBounds, iprotobuf.FieldBounds, error)

GetParentNonPayloadFieldBounds seeks parent's ID, signature and header in child object message and parses their boundaries.

If buf is empty, GetParentNonPayloadFieldBounds returns an error.

If any field is missing, no error is returned.

Message should have ascending field order, otherwise error returns.

func GetPayloadLengthAndFieldOffset added in v0.53.0

func GetPayloadLengthAndFieldOffset(buf []byte) (uint64, int, error)

GetPayloadLengthAndFieldOffset reads payload length header and seeks payload field in buf. If payload field is missing, negative offset returns. Otherwise, the offset points to protobuf LV.

If any field is missing, no error is returned.

Message should have ascending field order, otherwise error returns.

func ReadHeaderPrefix

func ReadHeaderPrefix(r io.Reader) (*object.Object, []byte, error)

ReadHeaderPrefix reads up to object.MaxHeaderLen bytes and extracts header and the payload prefix.

func SetAttribute

func SetAttribute(dst *object.Object, attr, val string)

SetAttribute sets value for the object attribute. If the attribute already exists, SetAttribute overwrites its value.

func SetIntAttribute

func SetIntAttribute(dst *object.Object, attr string, val int)

SetIntAttribute sets int value for the object attribute. If the attribute already exists, SetIntAttribute overwrites its value.

func WriteWithoutPayload

func WriteWithoutPayload(w io.Writer, obj object.Object) error

WriteWithoutPayload writes the object header to the given writer without the payload.

Types

This section is empty.

Jump to

Keyboard shortcuts

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