mongodb / bson-rust

Encoding and decoding support for BSON in Rust
MIT License
400 stars 132 forks source link

RUST-1773 Merge duplicate extjson map parsing between OwnedOrBorrowedRawBsonVisitor and SeededVisitor #480

Closed abr-egn closed 2 months ago

abr-egn commented 3 months ago

RUST-1773

This puts responsibility for turning a Serde map into bson values squarely on OwnedOrBorrowedRawBsonVisitor; SeededVisitor's job is now to efficiently buffer those values.

In my plan for the 🎆Glorious Future🎆, OwnedOrBorrowedRawBsonVisitor will also be taking over for the other places that parse extjson (BsonVisitor, TryFrom<serde_json::Value>, crate::extjson::models) and will necessarily be getting more liberal in the forms it accepts, so this means that doesn't need to be mirrored in SeededVisitor as well.

With this, I think the separation of logic is clear enough that there's no need to further merge; the reasoning from your original work on why that would involve quite a bit of complication is still very valid.