nix-rust / nix

Rust friendly bindings to *nix APIs
MIT License
2.57k stars 650 forks source link

Add `From<libc::sockaddr_ll> for LinkAddr` #2396

Closed jonatanzeidler closed 1 month ago

jonatanzeidler commented 2 months ago

What does this PR do

This PR adds a impl From<libc::sockaddr_ll> for LinkAddr to help users of nix avoid unsafe code. See https://github.com/nix-rust/nix/issues/2059#issuecomment-1878463448 for reference.

Checklist:

jonatanzeidler commented 2 months ago

Do you consider the From implementation a change to the API that should be noted in the changelog?

SteveLauC commented 2 months ago

My current concert of this kind of conversion is that it can be unsafe since we have no guarantee from the values set in those raw libc types, see https://github.com/nix-rust/nix/issues/2327#issuecomment-2053587739

Do you consider the From implementation a change to the API that should be noted in the changelog?

No since they are newly-added things

jonatanzeidler commented 2 months ago

I filed an alternative PR (#2397) to address the concern of invalid data.