From a4d76bb64aca12d5e01b8124a4355052c5fc7abe Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Thu, 5 Sep 2024 14:07:00 -0400 Subject: [PATCH 1/2] Add doc comment warnings and add missing coverage --- src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 9e464b3..e80202e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -67,6 +67,9 @@ //! # } //! ``` +#![warn(missing_docs)] +#![warn(clippy::missing_docs_in_private_items)] + use std::convert::TryInto; use std::io::{Read, Write}; @@ -75,10 +78,16 @@ pub use ed_derive::*; /// An enum that defines the `ed` error types. #[derive(thiserror::Error, Debug)] pub enum Error { + // TODO: more variants + /// An error that occurs when decoding a value and encountering a byte that + /// was not in a valid expected range. #[error("Unexpected byte: {0}")] UnexpectedByte(u8), + /// An error that occurs when encoding an enum value that does not have an + /// encoding defined. #[error("Unencodable variant")] UnencodableVariant, + /// An io error that occurs when reading or writing bytes. #[error(transparent)] IOError(#[from] std::io::Error), } From 782ba3db0438f5e596ea588a3d9347741972f8ba Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Thu, 5 Sep 2024 14:11:11 -0400 Subject: [PATCH 2/2] Add doc comments to ed-derive --- src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index e80202e..28e8a97 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -169,6 +169,8 @@ pub trait Decode: Sized { /// `decode` would have no way to know where to stop reading. pub trait Terminated {} +/// Generates `Encode`, `Decode`, and `Terminated` impls for a fixed-size +/// integer type. macro_rules! int_impl { ($type:ty, $length:expr) => { impl Encode for $type { @@ -333,6 +335,7 @@ impl Decode for () { impl Terminated for () {} +/// Generates `Encode`, `Decode`, and `Terminated` implementations for tuples. macro_rules! tuple_impl { ($( $type:ident ),*; $last_type:ident) => { impl<$($type: Encode + Terminated,)* $last_type: Encode> Encode for ($($type,)* $last_type,) {