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

Method WriteBufferObject

go/fory/writer.go:591–612  ·  view source on GitHub ↗

WriteBufferObject writes a buffer object If a buffer callback is set and returns false, the buffer is written out-of-band

(bufferObject BufferObject)

Source from the content-addressed store, hash-verified

589// WriteBufferObject writes a buffer object
590// If a buffer callback is set and returns false, the buffer is written out-of-band
591func (c *WriteContext) WriteBufferObject(bufferObject BufferObject) {
592 // Check if we should write this buffer out-of-band
593 inBand := true
594 if c.bufferCallback != nil {
595 inBand = c.bufferCallback(bufferObject)
596 }
597
598 c.buffer.WriteBool(inBand)
599 if inBand {
600 // WriteData the buffer data in-band
601 size := bufferObject.TotalBytes()
602 c.buffer.WriteLength(size)
603 writerIndex := c.buffer.writerIndex
604 c.buffer.grow(size)
605 bufferObject.WriteTo(c.buffer.Slice(writerIndex, size))
606 c.buffer.writerIndex += size
607 if size > MaxInt32 {
608 c.SetError(SerializationErrorf("length %d exceeds max int32", size))
609 }
610 }
611 // If out-of-band, we just write false (already done above) and the data is handled externally
612}
613
614// WriteValue writes a polymorphic value with configurable reference tracking and type info.
615// This is used when the concrete type is not known at compile time.

Callers

nothing calls this directly

Calls 8

SetErrorMethod · 0.95
SerializationErrorfFunction · 0.85
WriteBoolMethod · 0.80
SliceMethod · 0.80
TotalBytesMethod · 0.65
growMethod · 0.65
WriteToMethod · 0.65
WriteLengthMethod · 0.45

Tested by

no test coverage detected