plabble-codec 0.1.0

Plabble Transport Protocol codec
Documentation
/// Plabble dynamic integer
pub mod dyn_int;

/// Plabble date timestamp
pub mod plabble_date;
mod slot_body;
mod slot_range;

pub use slot_body::SlotBody;
pub use slot_range::SlotRange;

use crate::abstractions::SerializationError;

/// Assertion method. Asserts that size is the required size and returns an error if not.
pub(crate) fn assert_len(slice: &[u8], required: usize) -> Result<(), SerializationError> {
    if slice.len() < required {
        Err(SerializationError::TooFewBytes(required - slice.len()))
    } else {
        Ok(())
    }
}