tokio-rs / bytes

Utilities for working with bytes
MIT License
1.91k stars 288 forks source link

is BytesMut based on ringbuffer? #583

Closed ghost closed 1 year ago

notgull commented 1 year ago

No, it's basically a Vec.

ghost commented 1 year ago

but it looks like a queue a vec looks like a stacke

ghost commented 1 year ago

why the bytes in BytesMut not move when i call get_u8() if its a vec

Darksonn commented 1 year ago

A BytesMut has a starting position too, so it can increment the starting position. It's not a ring buffer because it doesn't "wrap around" when you reach the end. The bytes are always stored contiguously.