#bson

bson-rs

Encoding and decoding support for BSON in Rust

3 releases

Uses old Rust 2015

0.1.0 May 28, 2015
0.0.3 May 24, 2015
0.0.2 Apr 9, 2015
0.0.1 Apr 8, 2015
Download history 5/week @ 2021-09-27 5/week @ 2021-10-04 1/week @ 2021-10-11 4/week @ 2021-10-18 2/week @ 2021-10-25 5/week @ 2021-11-01 4/week @ 2021-11-08 2/week @ 2021-11-15 2/week @ 2021-11-22 10/week @ 2021-11-29 4/week @ 2021-12-06 3/week @ 2021-12-13 2/week @ 2021-12-20 2/week @ 2021-12-27 18/week @ 2022-01-03 38/week @ 2022-01-10

61 downloads per month

MIT license

39KB
691 lines

bson-rs

Build Status crates.io

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

~1MB
~19K SLoC