MCPcopy
hub / github.com/segmentio/kafka-go / writeVarNullBytesFrom

Method writeVarNullBytesFrom

protocol/encode.go:328–341  ·  view source on GitHub ↗
(b Bytes)

Source from the content-addressed store, hash-verified

326}
327
328func (e *encoder) writeVarNullBytesFrom(b Bytes) error {
329 if b == nil {
330 e.writeVarInt(-1)
331 return nil
332 } else {
333 size := int64(b.Len())
334 e.writeVarInt(size)
335 n, err := io.Copy(e, b)
336 if err == nil && n != size {
337 err = fmt.Errorf("size of nullable bytes does not match the number of bytes that were written (size=%d, written=%d): %w", size, n, io.ErrUnexpectedEOF)
338 }
339 return err
340 }
341}
342
343func (e *encoder) writeVarInt(i int64) {
344 e.writeUnsignedVarInt(uint64((i << 1) ^ (i >> 63)))

Callers 1

writeToVersion2Method · 0.95

Calls 2

writeVarIntMethod · 0.95
LenMethod · 0.65

Tested by

no test coverage detected