shellrow / netdev

Cross-platform library for network interface and gateway. Written in Rust.
MIT License
65 stars 12 forks source link

[Feature Request] use `ipnet` crate return `IpNet` #88

Closed qinghon closed 1 hour ago

qinghon commented 4 hours ago

According to my observation, the IpNet implementation in netdev has a high degree of overlap with the ipnet create implementation, but the implementation in netdev has a netmask field that is not real useful. Is this netmask necessary? Can the ip.rs implementation be replaced by ipnet?

qinghon commented 4 hours ago

I've swapped it out locally with an ipnet test and everything seems to be working fine.

shellrow commented 1 hour ago

Thank you for the suggestion and feedback!

Originally, over two years ago, the IpNet (Ipv4Net and Ipv6Net) implementation was created to minimize dependencies for netdev, and at that time, I also wanted to keep serde as an optional feature (which is now optional in ipnet, so there's no issue anymore). As for the netmask field, I agree that it is not essential, and using the methods provided by ipnet would be more appropriate when needed.

Therefore, replacing the ip.rs implementation with ipnet (re-export) is not only acceptable but also beneficial for future maintenance. I have already made the replacement and completed testing.