Skip to content

feat: convert Enpoint into SocketAddr#1124

Merged
Dirbaio merged 1 commit intosmoltcp-rs:mainfrom
sunhaosheng:main
Feb 27, 2026
Merged

feat: convert Enpoint into SocketAddr#1124
Dirbaio merged 1 commit intosmoltcp-rs:mainfrom
sunhaosheng:main

Conversation

@sunhaosheng
Copy link

Motivation

smoltcp::wire::Endpoint already supports conversion from core::net::SocketAddr (and v4/v6 variants), but there is no reverse conversion back to SocketAddr.

In real integrations, this causes small but repeated friction when interacting with APIs or logging paths that use standard Rust socket address types:

  • Rewriting the same manual conversion logic in multiple places
  • Reduced ergonomics when bridging smoltcp types with core/std-based code
  • Asymmetric conversion API (SocketAddr -> Endpoint exists, reverse does not)

Proposed Solution

A direct conversion from Endpoint to core::net::SocketAddr should be added. This makes conversion support symmetrical and removes boilerplate when interoperating with the Rust networking ecosystem.

API Design

impl From<Endpoint> for ::core::net::SocketAddr {
    fn from(x: Endpoint) -> ::core::net::SocketAddr {
        ::core::net::SocketAddr::new(x.addr.into(), x.port)
    }
}

@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.27%. Comparing base (08bacc9) to head (2a8b2d6).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/wire/ip.rs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1124      +/-   ##
==========================================
- Coverage   81.28%   81.27%   -0.01%     
==========================================
  Files          81       81              
  Lines       24838    24841       +3     
==========================================
  Hits        20189    20189              
- Misses       4649     4652       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Dirbaio Dirbaio added this pull request to the merge queue Feb 27, 2026
Merged via the queue into smoltcp-rs:main with commit 805c4e0 Feb 27, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants