binary-codec 0.3.1

A binary codec for Rust that provides serialization and deserialization of data structures to and from binary formats.
Documentation
#[derive(Debug)]
pub enum SerializationError {
    /// Value is out of bounds (value, min, max)
    ValueOutOfBounds(i32, i32, i32),

    // Unexpected size (expected, actual)
    UnexpectedLength(usize, usize),

    /// Missing runtime length key
    MissingLengthByKey(String),

    /// Validation did fail for the data
    InvalidData(String),
}

#[derive(Debug)]
pub enum DeserializationError {
    /// Not enough bytes (bytes missing)
    NotEnoughBytes(usize),

    // Unexpected size (expected, actual)
    UnexpectedLength(usize, usize),

    /// Unknown enum discriminator
    UnknownDiscriminant(u8),

    /// Missing runtime length key
    MissingLengthByKey(String),

    /// Validation did fail for the data
    InvalidData(String),
}

pub trait BinarySerializer {
    fn to_bytes<T : Clone>(&self, config: Option<&mut SerializerConfig<T>>) -> Result<Vec<u8>, SerializationError>;
    fn write_bytes<T : Clone>(&self, buffer: &mut Vec<u8>, config: Option<&mut SerializerConfig<T>>) -> Result<(), SerializationError>;
}

pub trait BinaryDeserializer : Sized {
    fn from_bytes<T : Clone>(bytes: &[u8], config: Option<&mut SerializerConfig<T>>) -> Result<Self, DeserializationError>;
}

mod config;
pub mod utils;
pub mod dynamics;
pub mod fixed_int;
pub mod dyn_int;
pub mod variable;

pub use binary_codec_derive::{ToBytes, FromBytes};
pub use config::SerializerConfig;