From b480d2b3b355344f13440442f4cc0f378df455fa Mon Sep 17 00:00:00 2001 From: Victor Koenders Date: Thu, 14 Oct 2021 18:04:13 +0200 Subject: [PATCH] Added documentation for the src/ module. Added warning for missing docs, fixed missing docs in src/de/mod.rs --- src/config.rs | 3 +++ src/de/mod.rs | 2 ++ src/error.rs | 4 +++- src/lib.rs | 5 +++-- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/config.rs b/src/config.rs index 7c709be..8d2fc93 100644 --- a/src/config.rs +++ b/src/config.rs @@ -101,6 +101,9 @@ pub trait Config: InternalConfig { impl Config for T {} +/// The default config. By default this will be: +/// - Little endian +/// - Variable int encoding #[derive(Copy, Clone)] pub struct Default; diff --git a/src/de/mod.rs b/src/de/mod.rs index eed91f3..b6ea6e5 100644 --- a/src/de/mod.rs +++ b/src/de/mod.rs @@ -1,3 +1,5 @@ +//! Decoder-based structs and traits. + use crate::error::DecodeError; mod decoder; diff --git a/src/error.rs b/src/error.rs index 7ff8824..4a7a6f2 100644 --- a/src/error.rs +++ b/src/error.rs @@ -40,7 +40,7 @@ pub enum DecodeError { /// the max index of the enum. max: u32, - // The index of the enum that the decoder encountered + /// The index of the enum that the decoder encountered found: u32, }, @@ -48,8 +48,10 @@ pub enum DecodeError { Utf8(core::str::Utf8Error), } +/// Integer types. Used by [DecodeError]. These types have no purpose other than being shown in errors. #[non_exhaustive] #[derive(Debug)] +#[allow(missing_docs)] pub enum IntegerType { U16, U32, diff --git a/src/lib.rs b/src/lib.rs index 2701499..59e3dd7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ #![no_std] +#![warn(missing_docs)] //! Bincode is a crate for encoding and decoding using a tiny binary //! serialization strategy. Using it, you can easily go from having @@ -58,10 +59,10 @@ pub fn encode_into_slice( pub fn encode_into_slice_with_config( val: E, dst: &mut [u8], - _config: C, + config: C, ) -> Result { let writer = enc::write::SliceWriter::new(dst); - let mut encoder = enc::Encoder::<_, C>::new(writer); + let mut encoder = enc::Encoder::<_, C>::new(writer, config); val.encode(&mut encoder)?; Ok(encoder.into_writer().bytes_written()) }