JulianSchmid / etherparse

A rust library for parsing ethernet & ethernet using protocols.
Apache License 2.0
285 stars 54 forks source link

Support partial default initialization with `IpAuthHeader` & `Ipv6RawExtHeader` #67

Open JulianSchmid opened 1 year ago

JulianSchmid commented 1 year ago

It would be nice if one could simply write:

let header = IpAuthHeader{
    next_header: 123,
    icv: [1,2,3,4].into(),
    ..Default::default()
};

or

let header = Ipv6RawExtHeader{
    next_header: 123,
    payload: [1,2,3,4,5,6].into()
};

But this is currently not possible as the payload buffers are implemented via some private fields. In both of structs cases these private fields contain a buffer for options as well as a length for how much of the buffer is filled.

We can get around this limitation by moving the buffers into their own types and making them public.