rust-pcap / pcap

Rust language pcap library
Apache License 2.0
620 stars 144 forks source link

Add First version of LinkName enum for Linktype #145

Closed Stargateur closed 3 years ago

Stargateur commented 3 years ago

I don't like much magic number, I follow the link of Linktype for value and name but I would appreciate some external verification of the code.

Unfortunately, if we want to add "Unknown" variant for the enum this would make it bigger (if we want to keep the unknown value), I don't known what could be the best but in anycase, this is useful. I wish rust could have a way to have a builting way to consider this kind of enum and make every other value fall under a Unknown magic variant that doesn't take place but keep the original value.

sekineh commented 3 years ago

We might want to add impl Display for Linktype which uses get_name() for easy inspection of data.

Stargateur commented 3 years ago

We might want to add impl Display for Linktype which uses get_name() for easy inspection of data.

That out of scope of the goal of my PR. But yeah why not, also get_name return a allocated String, that quite strange if like it's look pcap lib return a static data. First we should maybe have a get_name_ref that return a &'static str.

Wojtek242 commented 3 years ago

I manually merged this branch as another PR introduced a very minor conflict. This is on master now.