Crate bson [] [src]

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 the BSON standard.

Basic usage

extern crate bson;
use std::io::Cursor;
use bson::{Bson, Document, encode_document, decode_document};

fn main() {
    let mut doc = Document::new();
    doc.insert("foo".to_owned(), Bson::String("bar".to_owned()));

    let mut buf = Vec::new();
    encode_document(&mut buf, &doc).unwrap();

    let doc = decode_document(&mut Cursor::new(&buf[..])).unwrap();
}

Reexports

pub use self::ordered::{ValueAccessError, ValueAccessResult};

Modules

oid
ordered
spec

Constants derived from the BSON Specification Version 1.0.

Macros

bson
doc

Structs

Decoder
Encoder

Enums

Bson

Possible BSON value types.

DecoderError

Possible errors that can arise during decoding.

EncoderError

Possible errors that can arise during encoding.

Functions

decode_document

Attempt to decode a Document from a byte stream.

encode_document

Attempt to encode a Document into a byte stream.

from_bson

Decode a BSON Value into a T Deserializable.

to_bson

Encode a T Serializable into a BSON Value.

Type Definitions

Array

Alias for Vec<Bson>.

DecoderResult

Alias for Result<T, DecoderError>.

Document

Alias for OrderedDocument.

EncoderResult

Alias for Result<T, EncoderError>.