-
Couldn't load subscription status.
- Fork 19
Remove ipnetwork from public API
#123
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
base: main
Are you sure you want to change the base?
Conversation
Export custom `IpNetwork` type instead. This will allow upgrading the `ipnetwork` crate to not be a breaking change.
665d967 to
eb2048f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 7 of 7 files at r1, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @MarkusPettersson98)
src/rule/ip.rs line 48 at r1 (raw file):
impl IpNetwork { pub fn new(ip: impl Into<IpAddr>, prefix: u8) -> IpNetwork { Self::new_checked(ip.into(), prefix).unwrap()
I wonder if we really need the unchecked version. I think the constructor requiring an explicit unwrap is a bit nicer.
|
|
By having Alternative solutions to this problem are welcome 😊 |
The only solution that I can think of is to set the dependency to |
|
For those who are interested the problem is better articulated in this RFC: https://rust-lang.github.io/rfcs/1977-public-private-dependencies.html |
|
So what's the plan, are you going with update to ipnetwork 0.21.1 or rolling out your own IpNetwork? |
There is currently no plan. I would like to revisit this sooner rather than later, but other stuff takes priority atm. Sorry:/ |
This PR tries to address a painpoint of maintaining
pfctl: Upgradingipnetworkis considered a breaking change becauseipnetworkis part of the public API.The upcoming release will bump the
ipnetworkcrate anyway, so lets take the opportunity to changepfctlsuch that the dependency onipnetworkjust becomes an implementation detail that any library consumer doesn't have to worry about.To solve this issue, I used the newtype pattern to expose an
IpNetworktype thatpfctlowns. To make the migration straightforward, I gave the new type the same name as the equivalent type in theipnetworkcrate, and I even relaxed the constructor a bit while adding more constructors for useconstcontexts.TODO
pfctlcodeIpNetworkhas to be exposed at all, of if we can get away by only exposing theIpdata typeIpNetworkconstructors - which one do we want / need?This change is