Consumes `size` bytes and returns them as an independent PacketBuffer.
(size int)
| 218 | // Consumes `size` bytes and returns them as an |
| 219 | // independent PacketBuffer. |
| 220 | func (b *packetBuffer) split(size int) packetBuffer { |
| 221 | if size > len(b.bytes) { |
| 222 | size = len(b.bytes) |
| 223 | } |
| 224 | newBuffer := packetBuffer{bytes: b.bytes[:size]} |
| 225 | |
| 226 | b.bytes = b.bytes[size:] |
| 227 | |
| 228 | return newBuffer |
| 229 | } |
| 230 | |
| 231 | // Returns the size that a structure will encode into. |
| 232 | // This fuction doesn't check that Write() will succeed, |