Expand description
§Babbel BSON
Fast, binary-safe BSON (Binary JSON) parser, serializer, and DOM engine in pure Rust. Adheres strictly to the official BSON specification (bsonspec.org) and Babbel’s SOLID architecture.
BSON maps cleanly to Babbel’s universal Value AST:
- Null ->
Value::Null - Boolean ->
Value::Bool - 32-bit & 64-bit Signed integers ->
Value::Integer(i128) - 64-bit IEEE 754 floats ->
Value::Float(f64) - UTF-8 Strings ->
Value::String(String) - Binary byte arrays ->
Value::Bytes(Vec<u8>) - Arrays ->
Value::Array(Vec<Value>) - Embedded documents / Objects ->
Value::Object(Vec<(String, Value)>)
§Quickstart
use babbel_bson::{from_bytes, to_vec, BsonEngine};
use babbel_core::Value;
let original = Value::Object(vec![
("database".into(), Value::String("mongodb".into())),
("port".into(), Value::Integer(27017)),
]);
let encoded = to_vec(&original).unwrap();
let decoded = from_bytes(&encoded).unwrap();
assert_eq!(original, decoded);Re-exports§
pub use ejson::EJsonMode;pub use ejson::from_extended_json;pub use ejson::to_extended_json;pub use engine::BsonEngine;pub use error::BsonError;pub use parser::Decoder;pub use parser::DecoderConfig;pub use parser::from_bytes;pub use pull::BsonPullEvent;pub use pull::BsonPullParser;pub use serializer::serialize_to_dest;pub use serializer::to_vec;pub use constants::*;
Modules§
- constants
- BSON (Binary JSON) element types, subtypes, and constants.
- ejson
- MongoDB Extended JSON v2 (Canonical & Relaxed) support.
- engine
- BSON Format Engine adhering to OCP and DIP.
- error
- Error types for BSON encoding and decoding.
- parser
- High-performance BSON decoder into universal
ValueAST. - pull
- Streaming zero-allocation pull parser for BSON payloads operating in O(1) memory.
- serializer
- High-performance BSON serializer for universal
ValueAST.
Enums§
- Value
- Universal hierarchical data value across XML, JSON, YAML, and Bencode representations.
Functions§
- from_
slice - Convenience alias parsing BSON from a byte slice into
Value.