Encodes N bytes, without any optimizations
(bytes []byte)
| 327 | |
| 328 | // Encodes N bytes, without any optimizations |
| 329 | func (buf *Buffer) WriteNBytesRaw(bytes []byte) (EncodeType, error) { |
| 330 | if !buf.Allows(FLAG_READ_N_BYTES) { |
| 331 | return Stateless, fmt.Errorf("n bytes encoding is not allowed") |
| 332 | } |
| 333 | |
| 334 | buf.commitUint(FLAG_READ_N_BYTES) |
| 335 | buf.end(bytes, Stateless) |
| 336 | |
| 337 | t, err := buf.WriteWord(uintToBytes(uint64(len(bytes))), false) |
| 338 | if err != nil { |
| 339 | return Stateless, err |
| 340 | } |
| 341 | |
| 342 | buf.commitBytes(bytes) |
| 343 | |
| 344 | // end this last write without creating a flag pointer |
| 345 | // this is a data blob, not a flag |
| 346 | buf.end([]byte{}, t) |
| 347 | |
| 348 | return t, nil |
| 349 | } |
| 350 | |
| 351 | func (buf *Buffer) Encode4Bytes(bytes []byte) []byte { |
| 352 | // If Bytes4Indexes has this value, then we can just use the index |
no test coverage detected