diff --git a/src/lib.rs b/src/lib.rs index 9e464b3..28e8a97 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), } @@ -160,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 { @@ -324,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,) {