-
Notifications
You must be signed in to change notification settings - Fork 144
RUST-1111 Support deserializing RawBson
from Bson
#331
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
RUST-1111 Support deserializing RawBson
from Bson
#331
Conversation
@@ -529,7 +529,7 @@ impl Bson { | |||
/// This function mainly used for [extended JSON format](https://docs.mongodb.com/manual/reference/mongodb-extended-json/). | |||
// TODO RUST-426: Investigate either removing this from the serde implementation or unifying | |||
// with the extended JSON implementation. | |||
pub(crate) fn into_extended_document(self) -> Document { | |||
pub(crate) fn into_extended_document(self, rawbson: bool) -> Document { |
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.
rather than implementing various MapAccess
structs, the Bson
deserializer instead converts things into their "extended document" form and then uses a single MapAccess
implementation to walk over the resultant document. The changes here modify this method to create the documents in the form that the raw BSON types expect where necessary.
/// Hint provided to the deserializer via `deserialize_newtype_struct` as to the type of thing | ||
/// being deserialized. | ||
#[derive(Debug, Clone, Copy)] | ||
enum DeserializerHint { |
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.
this was originally just used in the raw deserializer, but now that the non-raw deserializer needs to interpret these hints, I've moved it to the top level of the de
module.
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.
looks good, just a small typo fix
serde-tests/test.rs
Outdated
/// - deserializing a `T` from the raw BSON version of `expected_doc` produces `expected_value` | ||
/// - deserializing a `Document` from the raw BSON version of `expected_doc` produces | ||
/// `expected_doc` | ||
/// - serializering `expected_value` to BSON bytes matches the raw BSON bytes of `expected_doc` |
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.
/// - serializering `expected_value` to BSON bytes matches the raw BSON bytes of `expected_doc` | |
/// - serializing `expected_value` to BSON bytes matches the raw BSON bytes of `expected_doc` |
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.
"serializer-ing" lol, fixed
5e04426
to
0eba63f
Compare
RUST-1111
This PR adds support to the
Bson
-based deserializer (used inbson::from_bson
andbson::from_document
) for deserializing the owned raw BSON types, namelyRawBson
,RawDocumentBuf
, andRawArrayBuf
.