MCPcopy Create free account
hub / github.com/apache/fory / ReadByteSlice

Method ReadByteSlice

go/fory/reader.go:510–526  ·  view source on GitHub ↗

ReadByteSlice reads []byte with optional ref/type info

(refMode RefMode, readType bool)

Source from the content-addressed store, hash-verified

508
509// ReadByteSlice reads []byte with optional ref/type info
510func (c *ReadContext) ReadByteSlice(refMode RefMode, readType bool) []byte {
511 err := c.Err()
512 if refMode != RefModeNone {
513 if c.buffer.ReadInt8(err) == NullFlag {
514 return nil
515 }
516 }
517 if readType {
518 actual := TypeId(c.buffer.ReadUint8(err))
519 if actual != BINARY && actual != UINT8_ARRAY {
520 c.SetError(DeserializationErrorf("slice type mismatch: expected BINARY (%d) or UINT8_ARRAY (%d), got %d", BINARY, UINT8_ARRAY, actual))
521 return nil
522 }
523 }
524 size := c.ReadBinaryLength()
525 return c.buffer.ReadBinary(size, err)
526}
527
528// ReadStringSlice reads []string with optional ref/type info using LIST protocol
529func (c *ReadContext) ReadStringSlice(refMode RefMode, readType bool) []string {

Callers 2

readRemainingFieldMethod · 0.80
DeserializeFunction · 0.80

Calls 8

ErrMethod · 0.95
SetErrorMethod · 0.95
ReadBinaryLengthMethod · 0.95
DeserializationErrorfFunction · 0.85
ReadUint8Method · 0.80
TypeIdEnum · 0.50
ReadInt8Method · 0.45
ReadBinaryMethod · 0.45

Tested by

no test coverage detected