Crate serde_dbor[][src]

DBOR - Dq's Binary Object Representation

DBOR is a serialization format based on CBOR, designed for Rust, and optimized for speed and file size. It uses buffered reading and writing systems when interacting with io streams for maximum efficiency.

I created this because I needed to save and load a large 23MB CBOR file containing a huge tree structure, and it was taking 6 seconds to load and 60 seconds to save. However, now with DBOR, both the save and load times went down to 0.3 seconds, and the file size went down to 19MB. (that's a difference of 1:20 in read speed and 1:200 in write speed!)

Example Usage

(derived from serde_json's tutorial)

Cargo.toml

[dependencies]
serde = "*"
serde_derive = "*"
serde_dbor = "*"

main.rs

extern crate serde;
extern crate serde_dbor;

#[macro_use]
extern crate serde_derive;

use serde_dbor::Error;

#[derive(Serialize, Deserialize)]
struct Person {
    name: String,
    age: u8,
    phones: Vec<String>
}

fn example<'a>(data: &'a [u8]) => Result<(), Error> {
    // Parse the data into a Person object.
    let p: Person = serde_dbor::from_slice(data)?;

    // Do things just like with any other Rust data structure.
    println!("Please call {} at the number {}", p.name, p.phones[0]);

    Ok(())
}

Structs

Deserializer

A structure that deserializes DBOR into Rust values

Serializer

A structure for serializing Rust values into DBOR

Enums

Error

Every single possible error that can be thrown from either Serialization or Deserialization

Type

All storage types, including ones that exist solely for debugging purposes

Functions

from_reader

Deserialize an instance of type T from an IO stream of DBOR

from_slice

Deserialize an instance of type T from bytes of DBOR

to_vec

Serialize the given data structure as a DBOR byte vector

to_writer

Serialize the given data structure as DBOR into an IO stream

Type Definitions

Result

Alias for a Result with the error type serde_dbor::Error