-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How should we implement Valuable for Uuid? #87
Comments
On the one hand it seems like we could actually implement
It almost seems like something like this on the pub trait Valuable {
fn as_value(&self) -> Value;
// default impl that can be overridden
fn as_listable(&self) -> Option<&dyn Listable> {
self.as_value().as_listable()
}
..
} And remove the single subtrait constraint, supporting a default, and then any number of specialized alternative representations. That constraint might be there for a good reason though. |
This also makes me wonder a bit if there should be some kind of " |
A |
Hi! 👋
cc @QnnOkabayashi
Over in uuid-rs/uuid#583 we've been talking about adding unstable
valuable
support toUuid
and run into a bit of a design issue I wanted to get some input on.It looks like we've got two possible directions we can go in:
Uuid
as its text-based format and useValue::Displayable
(dyn Display
primitive value #86). This means end-users in the diagnostics use-case will see something resembling a UUID rather than a blob of bytes without needing to match on strings (assumingtracing
will eventually run all values throughvaluable
), but it means reconstructing aUuid
from thatdyn Display
will require more work.Uuid
as its raw byte format and useValue::Listable
. This is less work than 1, and a more accurate representation of the UUIDs internal structure, but if we want a text-based UUID we need to look at its stringly-typed name and parse it.This seems like a general question that authors of primitive value types like UUIDs and IP addresses are going to need to answer, so was looking for some input on what you all think is the direction that best aligns with the goals of the
valuable
project.The text was updated successfully, but these errors were encountered: