-
Notifications
You must be signed in to change notification settings - Fork 12.1k
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
Add a method to get the in6_addr from an Ipv6Addr? #27264
Comments
I pretty much interpret it as a request to expose |
Yeah I've wanted this in the past as well from time to time, and there's a few consequences to doing this.
Overall, however, I think this is fine to do. I'd like a bit more discussion to make sure there's consensus (as impls are insta-stable), but the traits we could implement are:
|
Oh yes, same thing for the socket addresses, good spot. The relevant C structures are already public in the crates-io crate. |
Triage: no change. Usually, I'd suggest that minor additions like this don't deserve to have an issue open tracking them, especially since nobody has commented in over a year. However, due to @alexcrichton 's comment, it seems like this might not be a super minor addition. @rust-lang/libs what do you think? |
We've backpedaled pretty hard on exposing C types due to platform differences and such. A change like this would force our hand in exporting public |
Makes sense. Let's give this a close then. |
I understand that there are downsides in exporting (I'd have happily commented more often if I'd thought that this was the right way to make a difference...!) Currently I don't think that I can write the conversions safely any better than this monstrosity. Seems like a lot of trouble for something that really could just be a cast. Did I miss something simpler? Are we happy that this is just how it has to be? |
@dimbleby so, additions to Rust these days happen in two ways: minor changes have a PR, major changes have an RFC. We don't really keep issues open to track possible additions, as in both cases, they'd be tracked by either the PR or in the RFCs repo. So, given that there's additional complexity here, an RFC issue and/or PR would be a better place to handle that discussion. Does that make sense? |
@steveklabnik - yes, thanks, that's a much more sensible position! TBH, given that I've already written the awful code, I suspect that working myself up into a full RFC / PR is going to be more trouble than I am motivated to go through. (And maybe that's a good thing; probably there should be a does-someone-not-only-care-but-actually-care-enough-to-push-for-this bar for such changes). |
How would you feel about adding a method to
std::net::Ipv6Addr
that returned either anin6_addr
or (equivalently) a[u16; 8]
in which theu16
s are in network order?My motivation is that I am writing a binding to a C library which naturally wants an
in6_addr
; on the Rust side I naturally have anIpv6Addr
. At the moment I think that I have to goaddr.segments()
and then manually convert each segment into network order viato_be()
.Of course I can do this - but the implementation of an
Ipv6Addr
already contains anin6_addr
so the upshot is thatsegments()
converted the segments to host order and now I have to convert them back again!Wouldn't it be nice to skip this double-conversion?
The text was updated successfully, but these errors were encountered: