Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add doc comment warnings and add missing coverage #22

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
//! # }
//! ```

#![warn(missing_docs)]
#![warn(clippy::missing_docs_in_private_items)]

use std::convert::TryInto;
use std::io::{Read, Write};

Expand All @@ -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),
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,) {
Expand Down
Loading