MCPcopy
hub / github.com/tinylib/msgp / WriteBytes

Method WriteBytes

msgp/write.go:450–469  ·  view source on GitHub ↗

WriteBytes writes binary as 'bin' to the writer

(b []byte)

Source from the content-addressed store, hash-verified

448
449// WriteBytes writes binary as 'bin' to the writer
450func (mw *Writer) WriteBytes(b []byte) error {
451 if uint64(len(b)) > math.MaxUint32 {
452 return ErrLimitExceeded
453 }
454 sz := uint32(len(b))
455 var err error
456 switch {
457 case sz <= math.MaxUint8:
458 err = mw.prefix8(mbin8, uint8(sz))
459 case sz <= math.MaxUint16:
460 err = mw.prefix16(mbin16, uint16(sz))
461 default:
462 err = mw.prefix32(mbin32, sz)
463 }
464 if err != nil {
465 return err
466 }
467 _, err = mw.Write(b)
468 return err
469}
470
471// WriteBytesHeader writes just the size header
472// of a MessagePack 'bin' object. The user is responsible

Callers 15

TestReadBytesBytesFunction · 0.95
TestReadZCBytesFunction · 0.95
TestReadMapKeyFunction · 0.95
BenchmarkSkipBytesFunction · 0.95
TestReadBytesFunction · 0.95
TestSkipFunction · 0.95
BenchmarkSkipFunction · 0.95
TestCopyNextFunction · 0.95
TestRemoveFunction · 0.95
TestReplaceFunction · 0.95
BenchmarkLocateFunction · 0.95
TestWriteBytesFunction · 0.95

Calls 4

prefix8Method · 0.95
prefix16Method · 0.95
prefix32Method · 0.95
WriteMethod · 0.95

Tested by 15

TestReadBytesBytesFunction · 0.76
TestReadZCBytesFunction · 0.76
TestReadMapKeyFunction · 0.76
BenchmarkSkipBytesFunction · 0.76
TestReadBytesFunction · 0.76
TestSkipFunction · 0.76
BenchmarkSkipFunction · 0.76
TestCopyNextFunction · 0.76
TestRemoveFunction · 0.76
TestReplaceFunction · 0.76
BenchmarkLocateFunction · 0.76
TestWriteBytesFunction · 0.76