| 137 | } |
| 138 | |
| 139 | func (e *Encoder) EncodeArrayHeader(n int) error { |
| 140 | // Major type 4: an array of data items. Arrays are also called lists, |
| 141 | // sequences, or tuples. The array's length follows the rules for |
| 142 | // byte strings (major type 2), except that the length denotes the |
| 143 | // number of data items, not the length in bytes that the array takes |
| 144 | // up. Items in an array do not need to all be of the same type. |
| 145 | // For example, an array that contains 10 items of any type would |
| 146 | // have an initial byte of 0b100_01010 (major type of 4, additional |
| 147 | // information of 10 for the length) followed by the 10 remaining |
| 148 | // items. |
| 149 | // |
| 150 | // https://tools.ietf.org/html/rfc7049#section-2.1 |
| 151 | return e.encodeTypedUint(TypeArray, uint64(n)) |
| 152 | } |
| 153 | |
| 154 | func (e *Encoder) encodeMapHeader(n int) error { |
| 155 | return e.encodeTypedUint(TypeMap, uint64(n)) |