Metadata appends the encoded metadata to b and returns the resulting slice.
(metadata []RefMetadata, b []byte)
| 894 | |
| 895 | // Metadata appends the encoded metadata to b and returns the resulting slice. |
| 896 | func (*Encoder) Metadata(metadata []RefMetadata, b []byte) []byte { |
| 897 | buf := encoding.Encbuf{B: b} |
| 898 | buf.PutByte(byte(Metadata)) |
| 899 | |
| 900 | for _, m := range metadata { |
| 901 | buf.PutUvarint64(uint64(m.Ref)) |
| 902 | |
| 903 | buf.PutByte(m.Type) |
| 904 | |
| 905 | buf.PutUvarint(2) // num_fields: We currently have two more metadata fields, UNIT and HELP. |
| 906 | buf.PutUvarintStr(unitMetaName) |
| 907 | buf.PutUvarintStr(m.Unit) |
| 908 | buf.PutUvarintStr(helpMetaName) |
| 909 | buf.PutUvarintStr(m.Help) |
| 910 | } |
| 911 | |
| 912 | return buf.Get() |
| 913 | } |
| 914 | |
| 915 | // EncodeLabels encodes the contents of labels into buf. |
| 916 | func EncodeLabels(buf *encoding.Encbuf, lbls labels.Labels) { |