Skip to content

feat(xpp): add SocketAddr type system, remove unused Error - #202

Merged
mivinci merged 1 commit into
mainfrom
claude/net-addr
May 28, 2026
Merged

mivinci merged 1 commit into
mainfrom
claude/net-addr

Conversation

@mivinci

@mivinci mivinci commented May 28, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add xpp::net::{Ipv4Addr, Ipv6Addr, IpAddr, SocketAddrV4, SocketAddrV6, SocketAddr} — 6 types mirroring Rust's std::net
  • Trivially copyable value types: Ipv4Addr (4B), Ipv6Addr (16B), SocketAddrV4 (8B), SocketAddrV6 (28B)
  • IpAddr / SocketAddr use Variant for the V4/V6 sum type
  • parse() via inet_pton, to_string() via inet_ntop, from_sockaddr()/to_sockaddr() for C-layer interop
  • Typed error handling (Tokio-style): AddrParseError enum with InvalidIpv4/InvalidIpv6/InvalidPort/InvalidFormat
  • Remove unused Error(int) type and error.h — only net/addr used it, now replaced by AddrParseError
  • Update cxx11_guard.cpp to use Result<void, int> instead of Result<void, Error>

Test plan

  • 66 unit tests: construction, parsing (valid/invalid), formatting round-trip, queries (loopback/unspecified/multicast/private), comparison, sockaddr interop
  • ctest -R xpp in build (C++14)
  • ctest -R xpp in build-cxx20 (C++20)

🤖 Generated with Claude Code

Add xpp::net::{Ipv4Addr, Ipv6Addr, IpAddr, SocketAddrV4, SocketAddrV6,
SocketAddr} — 6 types mirroring Rust's std::net. Trivially copyable
value types with parse/to_string/from_sockaddr/to_sockaddr interop.

Typed error handling (Tokio-style): AddrParseError enum replaces the
generic Error(int) for address parsing. Error(int) was unused outside
net/addr and is removed; error.h deleted. cxx11_guard updated.

66 unit tests covering construction, parsing, formatting, queries,
comparison, and sockaddr round-trip.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@mivinci
mivinci merged commit 2f6b38c into main May 28, 2026
5 checks passed
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.

1 participant