EncodeMsg encodes the message to the writer.
(writer *msgp.Writer)
| 146 | |
| 147 | // EncodeMsg encodes the message to the writer. |
| 148 | func (s StringSorted) EncodeMsg(writer *msgp.Writer) error { |
| 149 | if s == nil { |
| 150 | return writer.WriteNil() |
| 151 | } |
| 152 | err := writer.WriteArrayHeader(uint32(len(s))) |
| 153 | if err != nil { |
| 154 | return err |
| 155 | } |
| 156 | keys := make([]string, 0, len(s)) |
| 157 | for k := range s { |
| 158 | keys = append(keys, k) |
| 159 | } |
| 160 | sort.Strings(keys) |
| 161 | |
| 162 | for _, k := range keys { |
| 163 | err = writer.WriteString(k) |
| 164 | if err != nil { |
| 165 | return err |
| 166 | } |
| 167 | } |
| 168 | return nil |
| 169 | } |
| 170 | |
| 171 | // MarshalMsg encodes the message to the bytes. |
| 172 | func (s StringSorted) MarshalMsg(bytes []byte) ([]byte, error) { |