3个版本
使用旧的Rust 2015
| 0.1.0 |  | 
|---|---|
| 0.0.3 | 2015年5月24日 | 
| 0.0.2 | 2015年4月9日 | 
| 0.0.1 | 2015年4月8日 | 
#30 in #bson
每月下载 140 次
39KB
691 代码行
bson-rs
BSON在Rust中的编码和解码支持
[dependencies]
bson-rs = "*"
lib.rs:
BSON是一种二进制格式,其中零个或多个键/值对作为一个单一实体存储。我们称这个实体为文档。
此库支持BSON标准的1.0版本。
基本用法
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();
    }
}
依赖关系
~1.5MB
~25K SLoC