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

Method WriteStringHeader

msgp/write.go:522–533  ·  view source on GitHub ↗

WriteStringHeader writes just the string size header of a MessagePack 'str' object. The user is responsible for writing 'sz' more valid UTF-8 bytes to the stream.

(sz uint32)

Source from the content-addressed store, hash-verified

520// is responsible for writing 'sz' more valid UTF-8
521// bytes to the stream.
522func (mw *Writer) WriteStringHeader(sz uint32) error {
523 switch {
524 case sz <= 31:
525 return mw.push(wfixstr(uint8(sz)))
526 case sz <= math.MaxUint8:
527 return mw.prefix8(mstr8, uint8(sz))
528 case sz <= math.MaxUint16:
529 return mw.prefix16(mstr16, uint16(sz))
530 default:
531 return mw.prefix32(mstr32, sz)
532 }
533}
534
535// WriteStringFromBytes writes a 'str' object
536// from a []byte.

Callers 1

Calls 5

pushMethod · 0.95
prefix8Method · 0.95
prefix16Method · 0.95
prefix32Method · 0.95
wfixstrFunction · 0.85

Tested by 1