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

Method MarshalMsg

msgp/setof/generated.go:879–892  ·  view source on GitHub ↗

MarshalMsg encodes the message to the bytes.

(bytes []byte)

Source from the content-addressed store, hash-verified

877
878// MarshalMsg encodes the message to the bytes.
879func (s Byte) MarshalMsg(bytes []byte) ([]byte, error) {
880 if s == nil {
881 return msgp.AppendNil(bytes), nil
882 }
883 if len(s) == 0 {
884 return msgp.AppendArrayHeader(bytes, 0), nil
885 }
886 bytes = ensure(bytes, s.Msgsize())
887 bytes = msgp.AppendArrayHeader(bytes, uint32(len(s)))
888 for k := range s {
889 bytes = msgp.AppendByte(bytes, byte(k))
890 }
891 return bytes, nil
892}
893
894// AsSlice returns the set as a slice.
895func (s Byte) AsSlice() []byte {

Callers 1

TestByte_NilHandlingFunction · 0.95

Calls 5

MsgsizeMethod · 0.95
AppendNilFunction · 0.92
AppendArrayHeaderFunction · 0.92
AppendByteFunction · 0.92
ensureFunction · 0.70

Tested by 1

TestByte_NilHandlingFunction · 0.76