-
Notifications
You must be signed in to change notification settings - Fork 4
Add SNBT serialisation #44
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
Conversation
if I'm honest, this should already be complete. I have also added unit tests. Every unit test is matching against actual SNBT produced by Minecraft (1.21.1)* * actually, 1.21.1 doesn't allow nameless compound values yet, so I had to manually add those in (c. compound_with_basic_numbers and others)
I would rather we could keep them, but that would mean making escape_string_value and its module public
Norbiros
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, pretty good job! Sorry for the delay, but I was away from home for a while.
|
Not sure what happened there... will investigate tomorrow |
|
Finally figured out how to run Clippy and formatter. Should be fine now |
|
okay, I don't think I've done anything to cause that. Compiled and tested perfectly fine on my machine too can someone else have a look at that log? |
|
Sorry for the delay. Yeah, it wasn't your fault - it was a change introduced in recent versions of clippy. I fixed this issue in 8e0cd21, so please, just rebase your branch on top of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job
(just update your branch, so our checks can run)
|
it is done |
Currently, the various Nbt types only implement
std::fmt::Debug, which displays the internal structure and is very hard to read. A more readable format (for non-debugging purposes) would be to format the data as SNBT, completing one half of #32 in so doing.As such, I have implemented
std::fmt::DisplayonNbt,NbtTag, andNbtCompound, which produces valid SNBT matching the formatting used by Minecraft. I have also added various unit tests that match, again, the output produced by CrabNBT with real Minecraft SNBT output.Following the SNBT standard ensures a lossless representation of the data, moreover one that is easily machine parsable. This opens up the possibility of implementing
std::str::FromStrin the future, which would also handily complete the other side of #32.