You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// TODO: Modify to avoid a copy.letmut enc = Encoder::default();self.local.encode(&mut enc);assert!(enc.len() <= d.len());
d[..enc.len()].copy_from_slice(enc.as_ref());
It should be possible to create a codec that doesn't require ownership of the underlying buffer. My underlying long-term goal would be something akin to what we had for smoltcp, where the packet structure was able to abstract over mutability (e.g. the ipv6 Packet structure).
The text was updated successfully, but these errors were encountered:
This TODO has bugged me for a while and I have a long flight with a good bit of time in the airport today 😆 so I'll make a first pass at doing this... Comments and critiques on this are very much appreciated.
I let my enthusiasm get the better of me 😆 The current usage of the Encoder structure doesn't really play well with a backing buffer that is not growable.
Problem
There are some cases where the Encoder's capacity is treated as a limit (e.g. the neqo-thransport PacketBuilder). I think cases like this could play nice with a backing buffer of a fixed size with a managed offset. There are however many locations where this doesn't work so well, so I think it would be a significant lift to get a strict "smoltcp-like" packet structure.
Possible solution
I think the easiest solution would be to introduce a enum for the buffer backing the encoder with a Borrowed variant for slices and a Owned variant for Vec, similar to ManagedSlice. On encode, the Borrowed case could assert that the buffer still has space, and the Owned case could expand in size if needed. There may be other solutions, but I think this would be the simplest to implement. Comments and critiques would be very much welcomed.
See neqo-transport/src/tparams.rs:690:
It should be possible to create a codec that doesn't require ownership of the underlying buffer. My underlying long-term goal would be something akin to what we had for smoltcp, where the packet structure was able to abstract over mutability (e.g. the ipv6 Packet structure).
The text was updated successfully, but these errors were encountered: