consensus_encoding: decoder docs which are consensus specific
What changed, and why it matters
This commit only changes documentation comments in the consensus_encoding crate. It renames descriptions like 'Primitive decoders' to 'Primitive and combinator decoder types' and updates several function doc comments to say 'consensus decodable type' instead of 'object'. No code logic, signatures, or behavior changed. There is no security impact.
No action required. This is a documentation-only change with no security relevance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff is limited to comment edits in consensus_encoding/src/decode/decoders.rs and consensus_encoding/src/decode/mod.rs. It removes the module-level ‘//! Consensus Decoding Traits’ header, updates the crate-level doc line for decoders.rs, and rephrases multiple rustdoc comments for Decode, Decoder, VecDecoder, and the decode_from_* / check_decode functions to emphasize that they are consensus-encoding specific. No executable code, trait bounds, error handling, or public API changed.
Changed components
consensus_encoding/src/decode/decoders.rsconsensus_encoding/src/decode/mod.rsInspect captured patch +11 / −13
diff --git a/consensus_encoding/src/decode/decoders.rs b/consensus_encoding/src/decode/decoders.rs
index 7d9c714e..67acc579 100644
--- a/consensus_encoding/src/decode/decoders.rs
+++ b/consensus_encoding/src/decode/decoders.rs
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: CC0-1.0
-//! Primitive decoders.
+//! Primitive and combinator decoder types.
#[cfg(feature = "alloc")]
use alloc::vec::Vec;
@@ -141,7 +141,7 @@ impl Decoder for ByteVecDecoder {
}
}
-/// A decoder that decodes a vector of `T`s.
+/// A decoder for a vector of consensus decodable types.
///
/// The vector encoding must start with the number of items in the vector, encoded as a compact
/// size.
diff --git a/consensus_encoding/src/decode/mod.rs b/consensus_encoding/src/decode/mod.rs
index aa3e5fb0..2e7f0f90 100644
--- a/consensus_encoding/src/decode/mod.rs
+++ b/consensus_encoding/src/decode/mod.rs
@@ -1,7 +1,5 @@
// SPDX-License-Identifier: CC0-1.0
-//! Consensus Decoding Traits
-
pub mod decoders;
#[cfg(feature = "hex")]
@@ -10,7 +8,7 @@ use crate::error::{FromHexError, FromHexErrorInner};
use crate::ReadError;
use crate::{DecodeError, UnconsumedError};
-/// A Bitcoin object which can be consensus-decoded using a push decoder.
+/// A Bitcoin object which can be consensus decoded using a push decoder.
///
/// To decode something, create a [`Self::Decoder`] and push byte slices into it with
/// [`Decoder::push_bytes`], then call [`Decoder::end`] to get the result.
@@ -51,7 +49,7 @@ pub trait Decode {
fn decoder() -> Self::Decoder { Self::Decoder::default() }
}
-/// A push decoder for a consensus-decodable object.
+/// A push decoder that consumes bytes in chunks.
pub trait Decoder: Sized {
/// The type that this decoder produces when decoding is complete.
type Output;
@@ -132,7 +130,7 @@ impl DecoderStatus {
pub fn is_ready(&self) -> bool { matches!(self, Self::Ready) }
}
-/// Decodes an object from a hex string without heap allocations.
+/// Decodes a consensus decodable type from a hex string without heap allocations.
///
/// # Errors
///
@@ -232,7 +230,7 @@ fn decode_from_hex_internal<D: Decoder>(
}
}
-/// Decodes an object from a byte slice.
+/// Decodes a consensus decodable type from a byte slice.
///
/// # Errors
///
@@ -278,7 +276,7 @@ fn decode_from_slice_internal<D: Decoder>(
}
}
-/// Decodes an object from an unbounded byte slice.
+/// Decodes a consensus decodable type from an unbounded byte slice.
///
/// Unlike [`decode_from_slice`], this function will not error if the slice contains additional
/// bytes that are not required to decode. Furthermore, the byte slice reference provided to this
@@ -332,7 +330,7 @@ fn decode_from_slice_unbounded_internal<D: Decoder>(
decoder.end()
}
-/// Decodes an object from a buffered reader.
+/// Decodes a consensus decodable type from a buffered reader.
///
/// # Performance
///
@@ -412,7 +410,7 @@ where
}
}
-/// Decodes an object from an unbuffered reader using a fixed-size buffer.
+/// Decodes a consensus decodable type from an unbuffered reader using a fixed-size buffer.
///
/// For most use cases, prefer [`decode_from_read`] with a [`std::io::BufReader`]. This function is
/// only needed when you have an unbuffered reader which you cannot wrap. It will probably have
@@ -440,7 +438,7 @@ where
decode_from_read_unbuffered_with::<T, R, 4096>(reader)
}
-/// Decodes an object from an unbuffered reader using a custom-sized buffer.
+/// Decodes a consensus decodable type from an unbuffered reader using a custom-sized buffer.
///
/// For most use cases, prefer [`decode_from_read`] with a [`std::io::BufReader`]. This function is
/// only needed when you have an unbuffered reader which you cannot wrap. It will probably have
@@ -493,7 +491,7 @@ where
decoder.end().map_err(ReadError::Decode)
}
-/// Checks that the given bytes decode to the expected value, panicking if they don't.
+/// Checks that the given bytes decode to the expected consensus decodable value, panicking if they don't.
///
/// This is intended for tests only.
///
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.