DecodeRawBytes consumes a length-prefixed raw bytes from the buffer. If alloc is specified, it returns a copy the raw bytes rather than a sub-slice of the buffer.
(alloc bool)
| 237 | // If alloc is specified, it returns a copy the raw bytes |
| 238 | // rather than a sub-slice of the buffer. |
| 239 | func (b *Buffer) DecodeRawBytes(alloc bool) ([]byte, error) { |
| 240 | v, n := protowire.ConsumeBytes(b.buf[b.idx:]) |
| 241 | if n < 0 { |
| 242 | return nil, protowire.ParseError(n) |
| 243 | } |
| 244 | b.idx += n |
| 245 | if alloc { |
| 246 | v = append([]byte(nil), v...) |
| 247 | } |
| 248 | return v, nil |
| 249 | } |
| 250 | |
| 251 | // DecodeStringBytes consumes a length-prefixed raw bytes from the buffer. |
| 252 | // It does not validate whether the raw bytes contain valid UTF-8. |
no outgoing calls