doc/wg/network/notes/packetbuffer-review-2024-10-07.md
Some notes for Leon on PacketBuffer.
General notes:
PacketBufferMut impl?? It would be really nice if this file made clear what the externally-usable calls are and what the internal crap is. I guess that's the pub keyword? But the impl of PacketSliceMut is pub too...Starting in PacketBufferDyn:
reclaim_headroom, the comment could be more clear here. I think it's taking space from the buffer and giving it to the headroom? Maybe a quick diagram. So false would mean that there wasn't enough buffer space?reclaim_tailroom, it will presumably not move past the headroom marker.reset, what does it do to tailroom? It's unclear to me how reset is different from reclaim_headroomcopy_from_slice_or_err and append_from_slice_max, those apply to the buffer data itself, right? They could use comments. I don't really understand what they do from the names alone. I'm also not sure why these two functions exist? What makes them the "proper" interface?prepend_unchecked operation? I guess the idea is that the checks are already happening at compile time before calling this?In impl PacketBufferMut:
reset, that's a runtime assert, right? Is that necessary?For PacketSliceMut:
_inner is a u8 here. And the comment above it does nothing to help that. It seems to never be used because we just refer to self instead. I kind of thought it would be [u8] since it's a transmuted array of data...?new, the comments don't seem to match the code about starting with zero headroom. I think it starts with payload length, headroom bytes of headroom, and length - headroom bytes of tailroom.get_inner_slice_length()? It seems like it should be pretty optimized, but I'm wondering if it actually happens in practice. Also that the panic isn't there.data_slice and data_slice_mut have slightly different constructionsIn impl PacketBufferDyn for PacketSliceMut:
len() correct? The comment there looks plausible, but the implementation looks wrong.copy_from_slice_or_err eat up tailroom? I assumed it would write into the payload and error if it didn't fit in the payload (slice.len() - headroom - tailroom).