-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement bitwise operations for Ipv4Addr #2398
Comments
I don’t think arbitrary bitwise operations make sense. (What does it mean to XOR two addresses?) Is there anything other than masking? Would a dedicated |
Probably not unless there's an easy way to get that |
Well, how would you get that 255.255.255.0? |
Configuration file whose format you don't control? |
What about creating a concrete type for "255.255.255.0" like "SubnetMask", and define proper constructors to outlaw invalid ones. In this way we can be sure that only meaningful mask operations are done on IP addresses, in which bitwise operations are more of an implementation detail? |
For anyone still looking at this, the ipnet crate builds on the |
There is currently active pull request related: rust-lang/rust#113747, with related rust-lang/libs-team#235 |
This should be probably closed, then, in favour of those. |
It's natural and common to apply bitwise operations to IPv4 addresses. For instance if I have an IP address 192.168.1.23 and a netmask 255.255.255.0 I might want to calculate:
It's possible to do this by converting to
u32
and back, but I shouldn't have to.The text was updated successfully, but these errors were encountered: