I find that it is sometimes practical (mostly for simplicity's sake) to work with owned packets, e.g. TcpPacket<Vec<u8>>. However, currently it is impossible to obtain a reference to the payload (&'a [u8]) from a &'a TcpPacket<Vec<u8>>, because the payload() method is only implemented on TcpPacket<&'b T>, returning a &'b [u8]. On the other hand payload_mut is fine. It is not completely trivial to move the implementation of payload to the generic impl, becuase of the different lifetime which is relied on elsewhere. Would you consider adding a way to do this? Either by somehow making the current payload() more generic, or adding a new method.
Oh, oops, there's as_ref(). Sorry for the noise. I'm still not sure how to use it with TcpRepr::parse, without introducing an intermediate Packet<&..>.
I find that it is sometimes practical (mostly for simplicity's sake) to work with owned packets, e.g.
TcpPacket<Vec<u8>>
. However, currently it is impossible to obtain a reference to the payload (&'a [u8]
) from a&'a TcpPacket<Vec<u8>>
, because thepayload()
method is only implemented onTcpPacket<&'b T>
, returning a&'b [u8]
. On the other handpayload_mut
is fine. It is not completely trivial to move the implementation of payload to the generic impl, becuase of the different lifetime which is relied on elsewhere. Would you consider adding a way to do this? Either by somehow making the currentpayload()
more generic, or adding a new method.