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
Inquiry Regarding Mutable Packet Types After Recent Updates
I'm currently in the process of updating my codebase to incorporate the latest changes in the library. Could you clarify whether the Mutable*Packet types (e.g., MutableEthernetPacket) are still available but perhaps relocated or renamed, or if they have been entirely removed?
In prior versions, I depended extensively on mutable packet structures for layered parsing and modification. For instance, I would start with a MutableEthernetPacket and, based on conditional logic, narrow it down to more specific subtypes by extracting and mutating the payload—something akin to MutableIPv4Packet::from(ethernet.payload_mut()) (this is pseudocode reconstructed from memory and may not be precise). Importantly, any modifications made within these narrowed subtypes would propagate back to the parent packet, enabling seamless chaining of operations across layers.
Is this pattern of chaining mutable packet types while progressively narrowing them still supported in the current implementation? If not, what alternative approaches would you recommend for achieving similar mutable, layered packet manipulation?
Currently, Mutable*Packet types as in older versions are not provided — packet mutation is done by creating a mutable packet struct, modifying the required fields, and then serializing with to_bytes(), or by rebuilding the packet via the builder API.
This makes mutation explicit and safe, avoiding hidden side effects across layers.
If you need to propagate changes across higher layers (e.g., editing TCP and having IPv4/IPv6 + Ethernet updated), you can currently do this by re-packing the affected layers manually.
In the future, we may provide helper functions to make this easier, such as re-pack builders or cascade repack utilities that handle checksum/length updates automatically.
Ouch, will likely have to hold off on updating then until something is in place. As having to re-pack every layer any time a downstream field is manipulated sounds quite tedious and repetitive. I really liked the idea of fundamentally working off of a set array of bytes, and all modifications are made in place to that array. As narrowed layers of that packet array were just fundamentally a interpretation of the underlying bytes. It's actually why I chose this library in the first place.
This feature is now supported as of v0.24.0.
The new MutablePacket trait and its generic implementation GenericMutablePacket
allow zero-copy, cross-layer mutable packet chaining (e.g., Ethernet -> IPv4 -> UDP)
with changes automatically reflected across layers.
Activity
shellrow commentedon Aug 12, 2025
Thanks for the issue!
Currently, Mutable*Packet types as in older versions are not provided — packet mutation is done by creating a mutable packet struct, modifying the required fields, and then serializing with to_bytes(), or by rebuilding the packet via the builder API.
This makes mutation explicit and safe, avoiding hidden side effects across layers.
If you need to propagate changes across higher layers (e.g., editing TCP and having IPv4/IPv6 + Ethernet updated), you can currently do this by re-packing the affected layers manually.
In the future, we may provide helper functions to make this easier, such as re-pack builders or cascade repack utilities that handle checksum/length updates automatically.
ImVexed commentedon Aug 12, 2025
Ouch, will likely have to hold off on updating then until something is in place. As having to re-pack every layer any time a downstream field is manipulated sounds quite tedious and repetitive. I really liked the idea of fundamentally working off of a set array of bytes, and all modifications are made in place to that array. As narrowed layers of that packet array were just fundamentally a interpretation of the underlying bytes. It's actually why I chose this library in the first place.
shellrow commentedon Nov 9, 2025
This feature is now supported as of v0.24.0.
The new
MutablePackettrait and its generic implementationGenericMutablePacketallow zero-copy, cross-layer mutable packet chaining (e.g., Ethernet -> IPv4 -> UDP)
with changes automatically reflected across layers.
Example:
examples/mutable_chaining.rshttps://github.com/shellrow/nex/releases/tag/v0.24.0