Skip to content

Introduce UnicastLinkLocal IP address types - #84

Merged
taspelund merged 3 commits into
mainfrom
trey/unicast-link-local-ip
Aug 12, 2026
Merged

Introduce UnicastLinkLocal IP address types#84
taspelund merged 3 commits into
mainfrom
trey/unicast-link-local-ip

Conversation

@taspelund

Copy link
Copy Markdown
Contributor

Adds UnicastLinkLocal types that wrap IpAddr, Ipv4Addr and Ipv6Addr. These guarantee at time of construction that the wrapped IP is both unicast and link-local in scope.

@taspelund taspelund self-assigned this Aug 11, 2026
@taspelund taspelund added the rust Pull requests that update rust code label Aug 11, 2026
Comment thread src/ipaddr.rs Outdated

@jgallagher jgallagher left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took a quick first look - just leaving a few high-ish level observations

Comment thread src/ipaddr.rs
Comment thread src/ipaddr.rs
Comment thread src/ipaddr.rs

schemars::schema::SchemaObject {
subschemas: Some(Box::new(schemars::schema::SubschemaValidation {
one_of: Some(vec![

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know JsonSchema well enough to review manual impls. Is the wire format for all of these essentially strings (but restricted via regex to unicast IPs)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, exactly. The regex restricts it to the unicast link-local ranges (multicast link-local ranges are separate)

Comment thread src/ipaddr.rs Outdated
Comment thread src/ipaddr.rs Outdated
Comment thread src/ipaddr.rs Outdated
Comment thread src/ipaddr.rs Outdated
Comment thread src/ipaddr.rs Outdated
Comment thread src/ipaddr.rs
Adds UnicastLinkLocal types that wrap IpAddr, Ipv4Addr and Ipv6Addr.
These guarantee at time of construction that the wrapped IP is both
unicast and link-local in scope.

Signed-off-by: Trey Aspelund <trey@oxidecomputer.com>
impl Deref for ipv{4,6} types, yank extra constructors, cleanup parse
error chain, serialize and deserialize through std ip types.

Signed-off-by: Trey Aspelund <trey@oxidecomputer.com>
@taspelund
taspelund force-pushed the trey/unicast-link-local-ip branch from b9acc98 to cecfacf Compare August 12, 2026 01:14
@taspelund
taspelund requested review from ahl and jgallagher August 12, 2026 14:12

@ahl ahl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

Comment thread src/ipaddr.rs Outdated
Comment thread src/ipaddr.rs Outdated

@jgallagher jgallagher left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to Nicolas's rustdoc nits, but all the changes LGTM. Thanks!

Signed-off-by: Trey Aspelund <trey@oxidecomputer.com>
@taspelund
taspelund merged commit f502cc4 into main Aug 12, 2026
14 checks passed
@taspelund
taspelund deleted the trey/unicast-link-local-ip branch August 12, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants