MarshalMsg encodes the message to the bytes.
(bytes []byte)
| 33 | |
| 34 | // MarshalMsg encodes the message to the bytes. |
| 35 | func (s String) MarshalMsg(bytes []byte) ([]byte, error) { |
| 36 | if s == nil { |
| 37 | return msgp.AppendNil(bytes), nil |
| 38 | } |
| 39 | if len(s) == 0 { |
| 40 | return msgp.AppendArrayHeader(bytes, 0), nil |
| 41 | } |
| 42 | bytes = ensure(bytes, s.Msgsize()) |
| 43 | bytes = msgp.AppendArrayHeader(bytes, uint32(len(s))) |
| 44 | for k := range s { |
| 45 | bytes = msgp.AppendString(bytes, string(k)) |
| 46 | } |
| 47 | return bytes, nil |
| 48 | } |
| 49 | |
| 50 | // AsSlice returns the set as a slice. |
| 51 | func (s String) AsSlice() []string { |