88// licenses.
99
1010//! A very simple serialization framework which is used to serialize/deserialize messages as well
11- //! as ChannelsManagers and ChannelMonitors.
11+ //! as [`ChannelManager`]s and [`ChannelMonitor`]s.
12+ //!
13+ //! [`ChannelManager`]: crate::ln::channelmanager::ChannelManager
14+ //! [`ChannelMonitor`]: crate::chain::channelmonitor::ChannelMonitor
1215
1316use crate :: prelude:: * ;
1417use crate :: io:: { self , Read , Seek , Write } ;
@@ -40,8 +43,8 @@ use crate::util::byte_utils::{be48_to_array, slice_to_be48};
4043/// serialization buffer size
4144pub const MAX_BUF_SIZE : usize = 64 * 1024 ;
4245
43- /// A simplified version of std::io::Write that exists largely for backwards compatibility.
44- /// An impl is provided for any type that also impls std::io::Write.
46+ /// A simplified version of [` std::io::Write`] that exists largely for backwards compatibility.
47+ /// An impl is provided for any type that also impls [` std::io::Write`] .
4548///
4649/// (C-not exported) as we only export serialization to/from byte arrays instead
4750pub trait Writer {
@@ -175,21 +178,21 @@ impl<R: Read> Read for ReadTrackingReader<R> {
175178 }
176179}
177180
178- /// A trait that various rust-lightning types implement allowing them to be written out to a Writer
181+ /// A trait that various LDK types implement allowing them to be written out to a [` Writer`].
179182///
180183/// (C-not exported) as we only export serialization to/from byte arrays instead
181184pub trait Writeable {
182- /// Writes self out to the given Writer
185+ /// Writes ` self` out to the given [` Writer`].
183186 fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , io:: Error > ;
184187
185- /// Writes self out to a Vec<u8>
188+ /// Writes ` self` out to a ` Vec<u8>`.
186189 fn encode ( & self ) -> Vec < u8 > {
187190 let mut msg = VecWriter ( Vec :: new ( ) ) ;
188191 self . write ( & mut msg) . unwrap ( ) ;
189192 msg. 0
190193 }
191194
192- /// Writes self out to a Vec<u8>
195+ /// Writes ` self` out to a ` Vec<u8>`.
193196 #[ cfg( test) ]
194197 fn encode_with_len ( & self ) -> Vec < u8 > {
195198 let mut msg = VecWriter ( Vec :: new ( ) ) ;
@@ -215,64 +218,64 @@ impl<'a, T: Writeable> Writeable for &'a T {
215218 fn write < W : Writer > ( & self , writer : & mut W ) -> Result < ( ) , io:: Error > { ( * self ) . write ( writer) }
216219}
217220
218- /// A trait that various rust-lightning types implement allowing them to be read in from a Read
221+ /// A trait that various LDK types implement allowing them to be read in from a [` Read`].
219222///
220223/// (C-not exported) as we only export serialization to/from byte arrays instead
221224pub trait Readable
222225 where Self : Sized
223226{
224- /// Reads a Self in from the given Read
227+ /// Reads a ` Self` in from the given [` Read`].
225228 fn read < R : Read > ( reader : & mut R ) -> Result < Self , DecodeError > ;
226229}
227230
228- /// A trait that various rust-lightning types implement allowing them to be read in from a
229- /// `Read + Seek`.
231+ /// A trait that various LDK types implement allowing them to be read in from a
232+ /// [ `Read`]` + `[` Seek`] .
230233pub ( crate ) trait SeekReadable where Self : Sized {
231- /// Reads a Self in from the given Read
234+ /// Reads a ` Self` in from the given [` Read`].
232235 fn read < R : Read + Seek > ( reader : & mut R ) -> Result < Self , DecodeError > ;
233236}
234237
235- /// A trait that various higher-level rust-lightning types implement allowing them to be read in
236- /// from a Read given some additional set of arguments which is required to deserialize.
238+ /// A trait that various higher-level LDK types implement allowing them to be read in
239+ /// from a [` Read`] given some additional set of arguments which is required to deserialize.
237240///
238241/// (C-not exported) as we only export serialization to/from byte arrays instead
239242pub trait ReadableArgs < P >
240243 where Self : Sized
241244{
242- /// Reads a Self in from the given Read
245+ /// Reads a ` Self` in from the given [` Read`].
243246 fn read < R : Read > ( reader : & mut R , params : P ) -> Result < Self , DecodeError > ;
244247}
245248
246- /// A std::io::Read that also provides the total bytes available to read.
249+ /// A [` std::io::Read`] that also provides the total bytes available to be read.
247250pub ( crate ) trait LengthRead : Read {
248- /// The total number of bytes available to read.
251+ /// The total number of bytes available to be read.
249252 fn total_bytes ( & self ) -> u64 ;
250253}
251254
252- /// A trait that various higher-level rust-lightning types implement allowing them to be read in
255+ /// A trait that various higher-level LDK types implement allowing them to be read in
253256/// from a Read given some additional set of arguments which is required to deserialize, requiring
254257/// the implementer to provide the total length of the read.
255258pub ( crate ) trait LengthReadableArgs < P > where Self : Sized
256259{
257- /// Reads a Self in from the given LengthRead
260+ /// Reads a ` Self` in from the given [` LengthRead`].
258261 fn read < R : LengthRead > ( reader : & mut R , params : P ) -> Result < Self , DecodeError > ;
259262}
260263
261- /// A trait that various higher-level rust-lightning types implement allowing them to be read in
262- /// from a Read, requiring the implementer to provide the total length of the read.
264+ /// A trait that various higher-level LDK types implement allowing them to be read in
265+ /// from a [` Read`] , requiring the implementer to provide the total length of the read.
263266pub ( crate ) trait LengthReadable where Self : Sized
264267{
265- /// Reads a Self in from the given LengthRead
268+ /// Reads a ` Self` in from the given [` LengthRead`].
266269 fn read < R : LengthRead > ( reader : & mut R ) -> Result < Self , DecodeError > ;
267270}
268271
269- /// A trait that various rust-lightning types implement allowing them to (maybe) be read in from a Read
272+ /// A trait that various LDK types implement allowing them to (maybe) be read in from a [` Read`].
270273///
271274/// (C-not exported) as we only export serialization to/from byte arrays instead
272275pub trait MaybeReadable
273276 where Self : Sized
274277{
275- /// Reads a Self in from the given Read
278+ /// Reads a ` Self` in from the given [` Read`].
276279 fn read < R : Read > ( reader : & mut R ) -> Result < Option < Self > , DecodeError > ;
277280}
278281
@@ -291,8 +294,8 @@ impl<T: Readable> Readable for OptionDeserWrapper<T> {
291294 Ok ( Self ( Some ( Readable :: read ( reader) ?) ) )
292295 }
293296}
294- /// When handling default_values, we want to map the default-value T directly
295- /// to a OptionDeserWrapper<T> in a way that works for `field: T = t;` as
297+ /// When handling ` default_values` , we want to map the default-value T directly
298+ /// to a ` OptionDeserWrapper<T>` in a way that works for `field: T = t;` as
296299/// well. Thus, we assume `Into<T> for T` does nothing and use that.
297300impl < T : Readable > From < T > for OptionDeserWrapper < T > {
298301 fn from ( t : T ) -> OptionDeserWrapper < T > { OptionDeserWrapper ( Some ( t) ) }
@@ -314,7 +317,7 @@ impl Readable for U48 {
314317 }
315318}
316319
317- /// Lightning TLV uses a custom variable-length integer called BigSize. It is similar to Bitcoin's
320+ /// Lightning TLV uses a custom variable-length integer called ` BigSize` . It is similar to Bitcoin's
318321/// variable-length integers except that it is serialized in big-endian instead of little-endian.
319322///
320323/// Like Bitcoin's variable-length integer, it exhibits ambiguity in that certain values can be
@@ -380,7 +383,7 @@ impl Readable for BigSize {
380383
381384/// In TLV we occasionally send fields which only consist of, or potentially end with, a
382385/// variable-length integer which is simply truncated by skipping high zero bytes. This type
383- /// encapsulates such integers implementing Readable/ Writeable for them.
386+ /// encapsulates such integers implementing [` Readable`]/[` Writeable`] for them.
384387#[ cfg_attr( test, derive( PartialEq , Eq , Debug ) ) ]
385388pub ( crate ) struct HighZeroBytesDroppedBigSize < T > ( pub T ) ;
386389
@@ -532,7 +535,7 @@ impl Readable for [u16; 8] {
532535 }
533536}
534537
535- /// For variable-length values within TLV record where the length is encoded as part of the record.
538+ /// A type for variable-length values within TLV record where the length is encoded as part of the record.
536539/// Used to prevent encoding the length twice.
537540pub struct WithoutLength < T > ( pub T ) ;
538541
@@ -1042,7 +1045,9 @@ impl Readable for String {
10421045/// Only the character set and length will be validated.
10431046/// The character set consists of ASCII alphanumeric characters, hyphens, and periods.
10441047/// Its length is guaranteed to be representable by a single byte.
1045- /// This serialization is used by BOLT 7 hostnames.
1048+ /// This serialization is used by [`BOLT 7`] hostnames.
1049+ ///
1050+ /// [`BOLT 7`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md
10461051#[ derive( Clone , Debug , PartialEq , Eq ) ]
10471052pub struct Hostname ( String ) ;
10481053impl Hostname {
0 commit comments