Documentation
¶
Index ¶
- Constants
- Variables
- func CalculateConcatProtobufLength(nonPayloadLen uint64, payloadLen uint64) uint64
- func CalculatePayloadFieldTagLength(payloadLen uint64) int
- func ExtractHeaderAndPayload(data []byte) (*object.Object, []byte, error)
- func GetAttribute(hdr object.Object, attr string) string
- func GetIndexAttribute(hdr object.Object, attr string) (int, error)
- func GetIntAttribute(hdr object.Object, attr string) (int, error)
- func GetNonPayloadFieldBounds(buf []byte) (iprotobuf.FieldBounds, iprotobuf.FieldBounds, iprotobuf.FieldBounds, error)
- func GetParentNonPayloadFieldBounds(buf []byte) (iprotobuf.FieldBounds, iprotobuf.FieldBounds, iprotobuf.FieldBounds, error)
- func GetParentNonPayloadFieldBoundsHeader(buf []byte) (iprotobuf.FieldBounds, iprotobuf.FieldBounds, iprotobuf.FieldBounds, error)
- func GetPayloadLengthHeader(buf []byte) (uint64, error)
- func GetTypeHeader(buf []byte) (object.Type, error)
- func ReadHeaderPrefix(r io.Reader) (*object.Object, []byte, error)
- func SetAttribute(dst *object.Object, attr, val string)
- func SetIntAttribute(dst *object.Object, attr string, val int)
- func WriteWithoutPayload(w io.Writer, obj object.Object) error
- type WriterTo
Constants ¶
const MaxHeaderVarintLen = 3
MaxHeaderVarintLen is varint len of object.MaxHeaderLen.
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 ¶
var ErrAttributeNotFound = errors.New("attribute not found")
ErrAttributeNotFound is returned when some object attribute not found.
var ReplicateV2FirstAPIVersion = version.New(2, 27)
ReplicateV2FirstAPIVersion is an API version when ReplicateV2 was added.
Functions ¶
func CalculateConcatProtobufLength ¶ added in v0.57.0
CalculateConcatProtobufLength calculates length of concatenation of non-payload and payload object's fields in Protocol Buffers V3 format.
CalculateConcatProtobufLength assumes that empty payload has no field in the object message.
func CalculatePayloadFieldTagLength ¶ added in v0.57.0
CalculatePayloadFieldTagLength calculates length payload field tag for the object message in Protocol Buffers V3 format.
Returns zero for empty payload.
func ExtractHeaderAndPayload ¶
ExtractHeaderAndPayload extracts the header of an object from the given byte slice and also returns payload prefix.
func GetAttribute ¶
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 ¶
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 ¶
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 GetParentNonPayloadFieldBoundsHeader ¶ added in v0.54.0
func GetParentNonPayloadFieldBoundsHeader(buf []byte) (iprotobuf.FieldBounds, iprotobuf.FieldBounds, iprotobuf.FieldBounds, error)
GetParentNonPayloadFieldBoundsHeader is GetParentNonPayloadFieldBounds analogue accepting header.
func GetPayloadLengthHeader ¶ added in v0.54.0
GetPayloadLengthHeader reads payload length header's field. If field is missing, no error is returned.
Message should have ascending field order, otherwise error returns.
func GetTypeHeader ¶ added in v0.54.0
GetTypeHeader reads object type header's field. If field is missing, no error is returned.
Message should have ascending field order, otherwise error returns.
func ReadHeaderPrefix ¶
ReadHeaderPrefix reads up to object.MaxHeaderLen bytes and extracts header and the payload prefix.
func SetAttribute ¶
SetAttribute sets value for the object attribute. If the attribute already exists, SetAttribute overwrites its value.
func SetIntAttribute ¶
SetIntAttribute sets int value for the object attribute. If the attribute already exists, SetIntAttribute overwrites its value.