Skip to content

refactor(netwatch)!: improve platform feature-gating and don't reexport netdev types - #163

Merged
flub merged 5 commits into
mainfrom
Frando/refactor-platform-impls
Jul 14, 2026
Merged

flub merged 5 commits into
mainfrom
Frando/refactor-platform-impls

Conversation

@Frando

@Frando Frando commented Jun 15, 2026 •

Copy link
Copy Markdown
Member

Description

We currently reexport items from netdev on platforms supported by netdev, and recreate identical types on other platforms. This is brittle and easy to break.

We also relied on module-path-rewriting, which is hard to follow and easy to miss.

This PR fixes both by restructuring the platform impl. It now defines shared types in one place, and then delegates to platform impls in a very normal way. The platforms using netdev still share code, but we no longer re-export any types from netdev.

Also adds a check-external-types CI check to validate this.

Breaking Changes

  • changed: netwatch::interfaces::Ipv6AddrFlags is now netwatch's own type on every platform, instead of a re-export of netdev's Ipv6AddrFlags. The field names are unchanged; code that relied on the netdev type identity must use netwatch::interfaces::Ipv6AddrFlags.
  • changed: netwatch::interfaces::Interface no longer wraps or exposes netdev::Interface; it is self-owned. Interface::is_up, Interface::name, and Interface::addrs are unchanged. No netdev types remain in the public API.
  • changed: <Interface as Display> now prints "{index}. {name} up={is_up} addrs={addrs:?}" instead of "{index}. {name} {if_type:?} ipv4={..} ipv6={..}".
  • changed: interfaces::State now has the same public fields on every platform. On wasm this adds the public local_addresses field and makes is_expensive and default_route_interface public; the never-populated http_proxy and pac fields are gone.

Notes & open questions

Change checklist

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant.
  • All breaking changes documented.

@github-actions

github-actions Bot commented Jun 15, 2026 •

Copy link
Copy Markdown

Documentation for this PR has been generated and is available at: https://n0-computer.github.io/net-tools/pr/163/docs/net_tools/

Last updated: 2026-07-14T14:56:07Z

@Frando Frando mentioned this pull request Jun 15, 2026
3 of 4 tasks
Base automatically changed from has_netdev to main June 15, 2026 10:12
@Frando
Frando force-pushed the Frando/refactor-platform-impls branch from ac13c84 to 86ded18 Compare June 15, 2026 10:16
@n0bot n0bot Bot added this to iroh Jun 15, 2026
@github-project-automation github-project-automation Bot moved this to 🚑 Needs Triage in iroh Jun 15, 2026
Frando added 2 commits July 13, 2026 23:42
The `derive_more` dependency was declared for three targets but used in
only one. Fold it into a single base dependency and use its `Display`
derive for `Interface` in place of the hand-written impl.
@Frando
Frando force-pushed the Frando/refactor-platform-impls branch from 86ded18 to 2c3b6c7 Compare July 13, 2026 21:59
The external-types job inherited the workflow-wide `RUSTDOCFLAGS=-Dwarnings`,
so unrelated rustdoc lints from the analyzer's internal rustdoc run turned
into hard failures. Clear `RUSTDOCFLAGS` for that job.

Install cargo-make, cargo-check-external-types, and wasm-bindgen-cli through
`taiki-e/install-action` rather than `cargo-binstall`, which pulled its own
latest build on every run. Bump `cargo-check-external-types` to 0.5.0 with
the matching nightly, kept in sync with `Makefile.toml`.
@Frando
Frando marked this pull request as ready for review July 13, 2026 22:17
@Frando
Frando force-pushed the Frando/refactor-platform-impls branch from 13a3499 to 053eabb Compare July 13, 2026 22:20
Comment thread netwatch/Cargo.toml Resolved
Comment thread netwatch/src/interfaces.rs Resolved
Comment thread netwatch/src/interfaces/netdev_impl.rs Resolved
@flub

flub commented Jul 14, 2026

Copy link
Copy Markdown
Member

I think this needs a breaking changes section of some sort, even if it is not listing individual things.

Frando added 2 commits July 14, 2026 15:25
Tighten the check-external-types allowlist from star imports to the
specific `noq_udp` and `n0_watcher` types that appear in the public API.
Document every `Interface` and `Ipv6AddrFlags` field, tracing each flag
to its OS source, and give module and item docs proper summary lines.
@flub
flub merged commit dab9883 into main Jul 14, 2026
30 checks passed
@github-project-automation github-project-automation Bot moved this from 🚑 Needs Triage to ✅ Done in iroh Jul 14, 2026
@ramfox
ramfox deleted the Frando/refactor-platform-impls branch July 14, 2026 17:41
@ramfox ramfox mentioned this pull request Jul 17, 2026
@Frando Frando mentioned this pull request Jul 21, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants