[][src]Crate bson

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 bson::{decode_document, encode_document, Bson, Document};
use std::io::Cursor;

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();
}

Re-exports

pub use self::ordered::ValueAccessError;
pub use self::ordered::ValueAccessResult;

Modules

compat

Backward compatibility

macros
oid

ObjectId

ordered

A BSON document represented as an associative HashMap with insertion ordering.

spec

Constants derived from the BSON Specification Version 1.0.

Macros

bson

Construct a bson::BSON value from a literal.

doc

Construct a bson::Document value.

Structs

Decoder

Serde Decoder

Encoder

Serde Encoder

TimeStamp

TimeStamp representation in struct for serde serialization

UtcDateTime

DateTime representation in struct for serde serialization

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.

decode_document_utf8_lossy

Attempt to decode a Document that may contain invalid UTF-8 strings 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>.