Skip to content
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
23 changes: 9 additions & 14 deletions src/preamble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,26 @@ where
Ok(())
}

/// Read and decode a connection preamble using bincode.
/// Asynchronously read and decode a connection preamble using bincode.
///
/// This helper reads the exact number of bytes required by `T`, as
/// indicated by [`DecodeError::UnexpectedEnd`]. Additional bytes are
/// requested from the reader until decoding succeeds or fails for some
/// requested from `reader` until decoding succeeds or fails for some
/// other reason.
///
/// # Errors
///
/// Returns a [`DecodeError`] if decoding the preamble fails or an
/// Asynchronously reads and decodes a preamble of type `T` from an async reader using bincode.
///
/// Attempts to decode a value of type `T` from the beginning of the byte stream, reading more bytes
/// as needed until decoding succeeds or an error occurs. Any bytes remaining after the decoded
/// value are returned as leftovers.
/// Attempts to decode a value of type `T` from the beginning of the
/// byte stream, reading more bytes as needed until decoding succeeds or
/// an error occurs. Any bytes remaining after the decoded value are
/// returned as leftovers.
///
/// # Returns
///
/// A tuple containing the decoded value and a vector of leftover bytes following the decoded
/// preamble.
/// A tuple containing the decoded value and any leftover bytes.
///
/// # Errors
///
/// Returns a `DecodeError` if decoding fails or if an I/O error occurs while reading from the
/// reader.
/// Returns a [`DecodeError`] if decoding fails or if an I/O error occurs
/// while reading from `reader`.
///
/// # Examples
///
Expand Down
Loading