Skip to content

Conversation

@JonathanWilbur
Copy link

Fixes #711

@JonathanWilbur
Copy link
Author

This currently isn't working. It seems that I have to make the ValueBag type support these new variants as well.

Example:

error[E0277]: the trait bound `ValueBag<'_>: From<std::net::SocketAddrV6>` is not satisfied
   --> src/kv/value.rs:388:39
    |
388 |                       Value::from_inner(value)
    |                       ----------------- ^^^^^ the trait `From<std::net::SocketAddrV6>` is not implemented for `ValueBag<'_>`
    |                       |
    |                       required by a bound introduced by this call
...

@KodrAus since you are the maintainer of the value-bag crate, would you take a PR to add variants for the core::net types, or is there a better way?

Copy link
Collaborator

@Thomasdezeeuw Thomasdezeeuw left a comment

Choose a reason for hiding this comment

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

I'm not sure about this. Where should we draw the line on what to support "natively" vs. using the fmt::Display implementation?

@KodrAus
Copy link
Contributor

KodrAus commented Dec 26, 2025

Since we capture types using ToValue by default, adding ToValue impls to types from the standard library seems ok to me. We can draw the line at anything that's in the standard library and has a well understood text-based format.

@JonathanWilbur for those missing From impls, I think we can just not add a by-value conversion from IpAddr to Value, and instead rely on the by-ref ToValue and From<&'_ T> conversions. Only primitive copy types like integers and booleans have by-value conversions into Value.

}

/// Visit an IP Address
fn visit_ip_addr(&mut self, value: IpAddr) -> Result<(), Error> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should expose visitors for these types, and instead let them fall through to visit_any.

@Thomasdezeeuw
Copy link
Collaborator

Since we capture types using ToValue by default, adding ToValue impls to types from the standard library seems ok to me. We can draw the line at anything that's in the standard library and has a well understood text-based format.

Makes sense to me 👍

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.

Implement ToValue for IpAddr, and SocketAddr

3 participants