WriteBufferObject writes a buffer object If a buffer callback is set and returns false, the buffer is written out-of-band
(bufferObject BufferObject)
| 589 | // WriteBufferObject writes a buffer object |
| 590 | // If a buffer callback is set and returns false, the buffer is written out-of-band |
| 591 | func (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. |
nothing calls this directly
no test coverage detected