Repository navigation
feat!: mark the public API as non_exhaustive where it will grow - #85
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, andIpSupport. RFC 4787 defines exactly three filtering modes, and callers often match onIpSupport.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::newis new for this purpose.Breaking changes
LabEventKindand each of its variants are#[non_exhaustive]. Amatchneeds a wildcard arm, and a pattern on a variant needs.., for exampleLabEventKind::RouterAdded { name, .. }.#[non_exhaustive], so amatchon them needs a wildcard arm:Firewall,PortPolicy,OutDir,Ipv6DadMode,Ipv6ProvisioningMode,Ipv6Profile,Nat,NatMapping,NatV6Mode, andRouterPreset.#[non_exhaustive]:LabEvent,DefaultRegions, andIfaceSnapshot,IfaceCounters,LabState,IxState,RouterState,DeviceState,RegionState, andRegionLinkStateinevent. Read their fields as before. A pattern on them needs...#[non_exhaustive]:RegionLink,FirewallConfig, andLabConfig,RegionConfig, andRouterConfiginconfig. Replace a struct literal with a constructor orDefault, then set the fields:RegionLink::good(ms)orRegionLink::degraded(ms)FirewallConfig::builder()LabConfig::default()andRegionConfig::default()RouterConfig::new(name), which is newNodeIdis private. Use itsDisplayimpl to print the number.