-
Notifications
You must be signed in to change notification settings - Fork 7
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
add serialization attributes for MacAddr enum #3
base: master
Are you sure you want to change the base?
Conversation
Hi, @alworx! As far as I remember, serde derives were not added for
I pushed 4c2305a into |
I see, you're perfectly right. |
I gave it a thought and it looks like current What I like that this implementation support both human-readable and machine representations, it's also applicable to our case here.
The only issue I see is that if human-readable repr will use hyphen-separated format (which I'm inclined to have), it will clash with current For reference, that's how formatting flags are used right now:
As an additional note to myself, introducing any of those changes should be considered as breaking change and will require major version bump. |
What's wrong with this approach? master...1Dragoon:rust-macaddr:master Though IMHO we should be outputting in such a way that the delimiters are kept to a minimum, assuming we use them at all. My preference for JSON in particular (and the way I'm using it for my own project) is to just output the literal hex string with no delimiters. This makes it very space efficient when you have a very large number of MAC addresses in a given JSON output. To make it more readable, I also use lowercase hex. Also, while it might make sense for IpAddr to have delimiters by default, I feel that MAC addresses should have none at all for the simple fact that there are no standard delimiters, which is different from IPv4 and IPv6. Thus, in a private fork, I made the default to_string() method output no delimiters with lowercase hex, while moving the colon delimiter to the plus sign. I also made the MacAddr6 output as 0102.0304.0506, also lowercase, which is a format common in networking equipment (I don't know where the splitting by three nibbles this crate uses comes from, I've never encountered that before.) |
I don't know if there is a particular reason for not having serde attributes on the MacAddr enum, but I needed this badly :)