Open Rossterd opened 2 years ago
The reason this happens is that the NBT deserializer reads bytes as requested, i.e. it does not parse the NBT before mapping it into Rust's data model. What's happening is that serde matches a NBT field named "biomes" to your BiomesV1_17
type, and then calls your type's Deserialize
implementation, expecting it to parse all bytes associated with the value of that field so that the next bytes in the reader are part of the next tag name. In the second example, when it tries to parse the next tag name, it runs into biome data, so it gets confused. All of this is to say that if your Deserialize
implementation gets invoked, you need to ensure that all the bytes constituting the value of your type are read.
I'm using quartz_nbt together with serde to deserialize chunk information, and I am getting the following possibly erroneous behaviour.
Works, but if I don't deserialize any data in my deserialize function like so:
I get the following error:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Custom("missing field `xPos`")'