bson-rs
Encoding and decoding support for BSON in Rust
Useful links
Installation
This crate works with Cargo and can be found on
crates.io with a Cargo.toml
like:
[]
= "0.4"
Usage
Link the library in main.rs:
extern crate bson;
Prepare your struct for Serde serialization:
Serialize the struct:
use bson;
let person = Person ;
let serialized_person = to_bson?; // Serialize
if let Document = serialized_person else
Deserialize the struct:
// Read the document from a MongoDB collection
let person_document = mongoCollection.find_one?
.expect;
// Deserialize the document into a Person instance
let person = from_bson?