cdr 0.2.0

A serialization/deserialization implementation of Common Data Representation
Documentation

cdr-rs

A serialization/deserialization implementation for Common Data Representation in Rust.

Build Status

Documentation

Usage

Add this to your Cargo.toml:

[dependencies]
cdr = { git = "https://github.com/hrektts/cdr-rs" }

Then add this to your crate:

extern crate cdr;

Example

extern crate cdr;
#[macro_use]
extern crate serde_derive;

use cdr::{CdrBe, Infinite};

#[derive(Deserialize, Serialize, PartialEq)]
struct Point {
    x: f64,
    y: f64,
}

#[derive(Deserialize, Serialize, PartialEq)]
struct Polygon(Vec<Point>);

fn main() {
    let triangle = Polygon(vec![Point { x: -1.0, y: -1.0 },
                                Point { x: 1.0, y: -1.0 },
                                Point { x: 0.0, y: 0.73 }]);

    let encoded = cdr::serialize::<_, _, CdrBe>(&triangle, Infinite).unwrap();
    let decoded = cdr::deserialize::<Polygon>(&encoded[..]).unwrap();

    assert!(triangle == decoded);
}

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

References