Crate cdr [−] [src]
A serialization/deserialization implementation for Common Data Representation.
Examples
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); }
Modules
de |
Deserializing CDR into Rust data types. |
ser |
Serializing Rust data types into CDR. |
size |
Measuring the size of (de)serialized data. |
Structs
Bounded |
A |
Deserializer |
A deserializer that reads bytes from a buffer. |
Error |
The Error type. |
Infinite |
A |
Serializer |
A serializer that writes values into a buffer. |
Enums
BigEndian |
Defines big-endian serialization. |
CdrBe |
OMG CDR big-endian encapsulation. |
CdrLe |
OMG CDR little-endian encapsulation. |
ErrorKind |
The kind of an error. |
LittleEndian |
Defines little-endian serialization. |
PlCdrBe |
ParameterList encapsulated using OMG CDR big-endian encapsulation. |
PlCdrLe |
ParameterList encapsulated using OMG CDR little-endian encapsulation. |
Traits
Encapsulation |
Data encapsulation scheme identifiers. |
SizeLimit |
Limits on the number of bytes that can be read or written. |
Functions
calc_serialized_size |
Returns the size that an object would be if serialized with a encapsulation. |
calc_serialized_size_bounded |
Given a maximum size limit, check how large an object would be if it were to be serialized with a encapsulation. |
deserialize |
Deserializes a slice of bytes into an object. |
deserialize_from |
Deserializes an object directly from a |
serialize |
Serializes a serializable object into a |
serialize_into |
Serializes an object directly into a |
Type Definitions
Result |
Convenient wrapper around |