Skip to content

feat!: mark the public API as non_exhaustive where it will grow - #85

Merged
Frando merged 5 commits into
mainfrom
api-cleanup
Nov 23, 2026
Merged

Frando merged 5 commits into
mainfrom
api-cleanup

Conversation

@Frando

@Frando Frando commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Most public enums and structs in patchbay are exhaustive today. A new NAT preset, a new event field, or a new config knob is then a breaking release. This PR marks the types that we expect to grow as #[non_exhaustive], so those additions become minor releases. The next release is breaking anyway.

Enums with closed sets stay exhaustive: LinkDirection, NatFiltering, and IpSupport. RFC 4787 defines exactly three filtering modes, and callers often match on IpSupport.

Input structs can no longer be built with a struct literal outside patchbay. Each one has a constructor or Default, and its fields stay public. RouterConfig::new is new for this purpose.

Breaking changes

  • LabEventKind and each of its variants are #[non_exhaustive]. A match needs a wildcard arm, and a pattern on a variant needs .., for example LabEventKind::RouterAdded { name, .. }.
  • These enums are #[non_exhaustive], so a match on them needs a wildcard arm: Firewall, PortPolicy, OutDir, Ipv6DadMode, Ipv6ProvisioningMode, Ipv6Profile, Nat, NatMapping, NatV6Mode, and RouterPreset.
  • These output structs are #[non_exhaustive]: LabEvent, DefaultRegions, and IfaceSnapshot, IfaceCounters, LabState, IxState, RouterState, DeviceState, RegionState, and RegionLinkState in event. Read their fields as before. A pattern on them needs ...
  • These input structs are #[non_exhaustive]: RegionLink, FirewallConfig, and LabConfig, RegionConfig, and RouterConfig in config. Replace a struct literal with a constructor or Default, then set the fields:
    • RegionLink::good(ms) or RegionLink::degraded(ms)
    • FirewallConfig::builder()
    • LabConfig::default() and RegionConfig::default()
    • RouterConfig::new(name), which is new
  • The value in NodeId is private. Use its Display impl to print the number.

Frando and others added 5 commits November 23, 2026 14:14
These enums hold presets and modes that we expect to extend: `Firewall`,
`PortPolicy`, `OutDir`, `Ipv6DadMode`, `Ipv6ProvisioningMode`,
`Ipv6Profile`, `Nat`, `NatMapping`, `NatV6Mode`, and `RouterPreset`. A new
variant then no longer breaks callers. A `match` on one of them outside
patchbay needs a wildcard arm.

`LinkDirection`, `NatFiltering`, and `IpSupport` stay exhaustive, because
their sets are closed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`LabEvent`, the snapshot and state structs in `event`, and
`DefaultRegions` are output types: patchbay builds them and callers read
them. A new field then no longer breaks callers. Code outside patchbay
can no longer build them with a struct literal, and a pattern needs `..`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`RegionLink`, `FirewallConfig`, and the TOML structs in `config` get new
knobs over time. A new field then no longer breaks callers.

Code outside patchbay can no longer build them with a struct literal. It
starts from a constructor or from `Default` and sets the public fields:
`RegionLink::good`, `FirewallConfig::builder`, `LabConfig::default`,
`RegionConfig::default`, and the new `RouterConfig::new`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The docs call `NodeId` opaque, but the public field let callers build
arbitrary ids and read the counter behind them. With the field private,
the id can change its form without a breaking release. `Display` still
prints the number.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The events carry fields that we extend over time. A new field on a
variant then no longer breaks callers. A pattern on a variant outside
patchbay needs `..`, and code outside patchbay can no longer build an
event.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Frando
Frando marked this pull request as ready for review November 23, 2026 14:12
@Frando
Frando merged commit 4f704e0 into main Nov 23, 2026
4 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