-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: BSON
-
None
serde based libraries have a somewhat stable layout of their APIs. The BSON library conforms to most of these ideas, but differs in some ways. We should strive to be as consistent with the other popular serde libraries to make using the BSON library natural for users of other popular libraries.
Here are some ways the BSON library differs:
Encode/Decode vs Serialize/Deserialize
The BSON library currently defines an Encoder and a Decoder, and uses verbs like decode and encode. In Rust, the verbs "serialize" and "deserialize" are more commonly used however (hence serde). We should rename our types to fit this pattern.
Namespacing
The BSON library currently uses prefixes for distinguishing between serialization types and deserialization types (e.g. DecoderResult and EncoderError). The other popular serde libraries (serde_json, toml, serde-xml-rs) split these into separate public modules ser and de. This helps to declutter the top-level namespace and organize types logically.
Value Type Name
Each of the other popular serde libraries (serde_json, toml, serde_yaml, serde-xml-rs) defines a top level type Value to refer to their value type (e.g. serde_json::Value). The BSON library calls it Bson. We should consider renaming this to Value to align with the other libraries. It can be disambiguated from them via the crate name (e.g. bson::Value).