Skip to content

Conversation

xyzzyz
Copy link

@xyzzyz xyzzyz commented Oct 20, 2025

Currently, the only way to create server_name::Ipv4Addr in no_std world is to parse it from string. This is somewhat suboptimal. This PR adds impl From<[u8; 4]> for Ipv4Addr, to parallel the already existing impl for Ipv6Addr.

Copy link
Member

@djc djc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a similar impl in core?

@ctz
Copy link
Member

ctz commented Oct 20, 2025

(An alternative to this, if you desire, is Ipv4Addr::new which would be const -- https://doc.rust-lang.org/std/net/struct.Ipv4Addr.html#method.new)

@ctz
Copy link
Member

ctz commented Oct 20, 2025

@xyzzyz
Copy link
Author

xyzzyz commented Oct 20, 2025

@ctz unfortunately, without std feature, there's no way to convert core::net::Ipv4Addr to rustls_pki_types::Ipv4Addr, hence my PR.

I guess one could replace the existing impl From<std::net::Ipv4Addr> for rustls_pki_types::Ipv4Addr that's feature-gated behind std feature with impl From<core::net::Ipv4Addr> for rustls_pki_types::Ipv4Addr and remove feature gating, WDYT?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants