3 releases
Uses old Rust 2015
0.1.0 |
|
---|---|
0.0.3 | May 24, 2015 |
0.0.2 | Apr 9, 2015 |
0.0.1 | Apr 8, 2015 |
#27 in #bson
36 downloads per month
39KB
691 lines
bson-rs
Encoding and decoding support for BSON in Rust
[dependencies]
bson-rs = "*"
lib.rs
:
BSON is a binary format in which zero or more key/value pairs are stored as a single entity. We call this entity a document.
This library supports Version 1.0 of BSON standard.
Basic usage
extern crate bson;
use std::io::Cursor;
use bson::{Bson, Document, Encoder, Decoder};
fn main() {
let mut doc = Document::new();
doc.insert("foo".to_string(), Bson::String("bar".to_string()));
let mut buf = Vec::new();
{
let mut enc = Encoder::new(&mut buf);
enc.encode_document(&doc).unwrap();
}
let mut r = Cursor::new(&buf[..]);
{
let mut dec = Decoder::new(&mut r);
let doc = dec.decode_document().unwrap();
}
}
Dependencies
~1.5MB
~24K SLoC