cobs/lib.rs
1#![cfg_attr(not(feature = "use_std"), no_std)]
2
3// In the future, don't do this.
4mod dec;
5mod enc;
6pub use crate::dec::*;
7pub use crate::enc::*;
8
9/// Calculates the maximum possible size of an encoded message given the length
10/// of the source message. This may be useful for calculating how large the
11/// `dest` buffer needs to be in the encoding functions.
12pub fn max_encoding_length(source_len: usize) -> usize {
13 source_len + (source_len / 254) + if source_len % 254 > 0 { 1 } else { 0 }
14}