2929//! data, and decode it. Using only the types which include a default [`CompactEncoding`]
3030//! implementation. A more ergonomic pattern is demonstrated in other examples
3131//! ```
32- //! use compact_encoding::encodable:: CompactEncoding;
32+ //! use compact_encoding::CompactEncoding;
3333//!
3434//! let number = 41_u32;
3535//! let word = "hi";
6262//! ```
6363//! use compact_encoding::{
6464//! map_decode, map_encode, sum_encoded_size, to_encoded_bytes,
65- //! {encodable:: CompactEncoding, EncodingError} ,
65+ //! CompactEncoding, EncodingError,
6666//! };
6767//!
6868//! #[derive(Debug, PartialEq)]
158158//! assert_eq!(bar_dec, bar);
159159//! # Ok::<(), Box<dyn std::error::Error>>(())
160160//! ```
161- mod types;
161+ pub mod types;
162162use std:: {
163163 any:: type_name,
164164 net:: { Ipv4Addr , Ipv6Addr } ,
165165} ;
166166
167- use crate :: types:: { EncodingError , U16_SIGNIFIER , U32_SIGNIFIER , U64_SIGNIFIER } ;
167+ pub use crate :: types:: { EncodingError , EncodingErrorKind } ;
168+
169+ /// indicates a variable width unsigned integer fits in u16
170+ pub const U16_SIGNIFIER : u8 = 0xfd ;
171+ /// indicates a variable width unsigned integer fits in u32
172+ pub const U32_SIGNIFIER : u8 = 0xfe ;
173+ /// indicates a variable width unsigned integer fits in u64
174+ pub const U64_SIGNIFIER : u8 = 0xff ;
168175
169176const U16_SIZE : usize = 2 ;
170177const U32_SIZE : usize = 4 ;
@@ -187,7 +194,7 @@ pub trait CompactEncoding<Decode: ?Sized = Self> {
187194 /// encoding to it in one step.
188195 /// ```
189196 /// # use std::net::Ipv4Addr;
190- /// # use compact_encoding::encodable:: CompactEncoding;
197+ /// # use compact_encoding::CompactEncoding;
191198 /// let foo: Ipv4Addr = "0.0.0.0".parse()?;
192199 /// let mut buff = vec![0; foo.encoded_size()?];
193200 /// foo.encode(&mut buff)?;
@@ -202,7 +209,7 @@ pub trait CompactEncoding<Decode: ?Sized = Self> {
202209 /// method for: encoding to it in one step.
203210 /// ```
204211 /// # use std::net::Ipv4Addr;
205- /// # use compact_encoding::encodable:: CompactEncoding;
212+ /// # use compact_encoding::CompactEncoding;
206213 /// let foo: Ipv4Addr = "0.0.0.0".parse()?;
207214 /// vec![0; foo.encoded_size()?];
208215 /// # Ok::<(), Box<dyn std::error::Error>>(())
@@ -271,7 +278,7 @@ pub trait BoxArrayEncodable: CompactEncoding {
271278/// [`CompactEncoding::encoded_size`] on all of them.
272279/// Note this is macro is useful when your arguments have differing types.
273280/// ```
274- /// # use crate::compact_encoding::{sum_encoded_size, encodable:: CompactEncoding};
281+ /// # use crate::compact_encoding::{sum_encoded_size, CompactEncoding};
275282/// # use std::net::Ipv4Addr;
276283/// let foo: Ipv4Addr = "0.0.0.0".parse()?;
277284/// let bar = 42u64;
@@ -296,7 +303,7 @@ macro_rules! sum_encoded_size {
296303/// Given a list of [`CompactEncoding`] things, create a zeroed buffer of the correct size for encoding.
297304/// Note this is macro is useful when your arguments have differing types.
298305/// ```
299- /// # use crate::compact_encoding::{create_buffer, encodable:: CompactEncoding};
306+ /// # use crate::compact_encoding::{create_buffer, CompactEncoding};
300307/// # use std::net::Ipv4Addr;
301308/// let foo: Ipv4Addr = "0.0.0.0".parse()?;
302309/// let bar = 42u64;
@@ -321,7 +328,7 @@ macro_rules! create_buffer {
321328/// Given a buffer and a list of [`CompactEncoding`] things, encode the arguments to the buffer.
322329/// Note this is macro is useful when your arguments have differing types.
323330/// ```
324- /// # use crate::compact_encoding::{create_buffer, map_encode, encodable:: CompactEncoding};
331+ /// # use crate::compact_encoding::{create_buffer, map_encode, CompactEncoding};
325332/// let num = 42u64;
326333/// let word = "yo";
327334/// let mut buff = create_buffer!(num, word);
@@ -356,7 +363,7 @@ macro_rules! map_encode {
356363/// ```
357364macro_rules! to_encoded_bytes {
358365 ( $( $val: expr) ,* ) => { {
359- use $crate:: { map_encode, create_buffer, encodable :: CompactEncoding } ;
366+ use $crate:: { map_encode, create_buffer, CompactEncoding } ;
360367 let mut buffer = create_buffer!( $( $val) ,* ) ;
361368 map_encode!( & mut buffer, $( $val) ,* ) ;
362369 buffer
@@ -380,7 +387,7 @@ macro_rules! map_decode {
380387 ( $buffer: expr, [
381388 $( $field_type: ty) ,* $( , ) ?
382389 ] ) => { {
383- use $crate:: encodable :: CompactEncoding ;
390+ use $crate:: CompactEncoding ;
384391 let mut current_buffer: & [ u8 ] = $buffer;
385392
386393 // Decode each type into `result_tuple`
0 commit comments