Copy no-export tags to new serialization traits
What changed, and why it matters
This commit adds documentation comments (no-export tags) to two new Rust traits so that automated binding generators know not to expose them to users of language bindings. It is a build/tooling metadata fix, not a code behavior change. There is no direct security impact, but missing tags could previously have caused generated bindings to expose low-level streaming-read APIs that are not intended for bindings users.
No immediate security action required. Treat as a normal build/API-hygiene fix. If auditing generated bindings, verify that `LengthLimitedRead` and `LengthReadable` are no longer emitted in public bindings for the next release.
Security signals we found
Missing API-surface restriction for generated language bindings
Low-level stream-read traits potentially exposed to bindings consumers
No runtime code change; risk is limited to generated API surface
Evidence from the diff
The patch adds /// This is not exported to bindings users as reads are always from byte arrays, never streams, in bindings. comments to the LengthLimitedRead trait, its FixedLengthReader implementation, and the LengthReadable trait in lightning/src/util/ser.rs. These comments are consumed by LDK’s bindings generator to exclude items from the public C/Java/Swift/etc. API surface. The change is purely additive documentation metadata; no logic, signatures, or runtime behavior are modified.
Changed components
lightning/src/util/ser.rsLengthLimitedRead traitLengthReadable traitFixedLengthReader LengthLimitedRead implLDK language bindings generator metadataInspect captured patch +8 / −0
diff --git a/lightning/src/util/ser.rs b/lightning/src/util/ser.rs
index d78b3e9..f821aa5 100644
--- a/lightning/src/util/ser.rs
+++ b/lightning/src/util/ser.rs
@@ -229,6 +229,8 @@ impl<'a, R: Read> Read for FixedLengthReader<'a, R> {
}
}
+/// This is not exported to bindings users as reads are always from byte arrays, never streams, in
+/// bindings.
impl<'a, R: Read> LengthLimitedRead for FixedLengthReader<'a, R> {
#[inline]
fn remaining_bytes(&self) -> u64 {
@@ -350,6 +352,9 @@ where
/// A [`io::Read`] that limits the amount of bytes that can be read. Implementations should ensure
/// that the object being read will only consume a fixed number of bytes from the underlying
/// [`io::Read`], see [`FixedLengthReader`] for an example.
+///
+/// This is not exported to bindings users as reads are always from byte arrays, never streams, in
+/// bindings.
pub trait LengthLimitedRead: Read {
/// The number of bytes remaining to be read.
fn remaining_bytes(&self) -> u64;
@@ -379,6 +384,9 @@ where
///
/// Any type that implements [`Readable`] also automatically has a [`LengthReadable`]
/// implementation, but some types, most notably onion packets, only implement [`LengthReadable`].
+///
+/// This is not exported to bindings users as reads are always from byte arrays, never streams, in
+/// bindings.
pub trait LengthReadable
where
Self: Sized,
Why this scored 18/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.