3 ms·
Out of interest, how do you compare/store in a map? Do you convert to a string, or a [4]byte array (for IPv4), or some other comparable/hashable type?
by benhoyt 6y ago
Out of interest, how do you compare/store in a map? Do you convert to a string, or a [4]byte array (for IPv4), or some other comparable/hashable type?
- tptacek 6y agoEither strings or (in the common case where I know I'm dealing with v4) uint32's. In fact, I probably do v6 stuff with uint32s too (I'm never working with an arbitrarily large v6 prefix). I think this post is right about net.IP, though I also think the solution they've reached is Lovecraftian. But I write Rust, too, and I'd take net.IP over Sockaddr any day of the week.
- comex 6y agoI assume you mean std::net::SocketAddr? Out of curiosity, what's wrong with it?
- ATsch 6y agoI'd assume the lackluster selection of operations and how deeply nested some of the information is within the type. Definitely not the most ergonomic thing. My personal favorite is probably the python ones. Only annoyance is difficulty of creating modified objects from existing ones.