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

Fix "one type is more general" error #73

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
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: 6 additions & 6 deletions src/tls_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub struct TlsEncrypted<'a> {

/// Tls Record with raw (unparsed) data
///
/// Use `parse_tls_raw_record` to parse content
/// Use [`parse_tls_raw_record`] to parse content
#[derive(Clone, Debug, PartialEq)]
pub struct TlsRawRecord<'a> {
pub hdr: TlsRecordHeader,
Expand All @@ -80,7 +80,7 @@ pub struct TlsRawRecord<'a> {
///
/// This function is used to get the record header.
/// After calling this function, caller can read the expected number of bytes and use
/// `parse_tls_record_with_header` to parse content.
/// [`parse_tls_record_with_header`] to parse content.
#[inline]
pub fn parse_tls_record_header(i: &[u8]) -> IResult<&[u8], TlsRecordHeader> {
TlsRecordHeader::parse(i)
Expand Down Expand Up @@ -133,7 +133,7 @@ pub fn parse_tls_encrypted(i: &[u8]) -> IResult<&[u8], TlsEncrypted> {
///
/// This function is used to get the record type, and to make sure the record is
/// complete (not fragmented).
/// After calling this function, use `parse_tls_record_with_header` to parse content.
/// After calling this function, use [`parse_tls_record_with_header`] to parse content.
pub fn parse_tls_raw_record(i: &[u8]) -> IResult<&[u8], TlsRawRecord> {
let (i, hdr) = parse_tls_record_header(i)?;
if hdr.len > MAX_RECORD_LEN {
Expand All @@ -145,7 +145,7 @@ pub fn parse_tls_raw_record(i: &[u8]) -> IResult<&[u8], TlsRawRecord> {

/// Parse one packet only, as plaintext
///
/// This function is deprecated. Use `parse_tls_plaintext` instead.
/// This function is deprecated. Use [`parse_tls_plaintext`] instead.
///
/// This function will be removed from API, as the name is not correct: it is
/// not possible to parse TLS packets without knowing the TLS state.
Expand All @@ -157,8 +157,8 @@ pub fn tls_parser(i: &[u8]) -> IResult<&[u8], TlsPlaintext> {

/// Parse one chunk of data, possibly containing multiple TLS plaintext records
///
/// This function is deprecated. Use `parse_tls_plaintext` instead, checking if
/// there are remaining bytes, and calling `parse_tls_plaintext` recursively.
/// This function is deprecated. Use [`parse_tls_plaintext`] instead, checking if
/// there are remaining bytes, and calling [`parse_tls_plaintext`] recursively.
///
/// This function will be removed from API, as it should be replaced by a more
/// useful one to handle fragmentation.
Expand Down
8 changes: 4 additions & 4 deletions src/tls_sign_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ pub fn parse_digitally_signed(i: &[u8]) -> IResult<&[u8], DigitallySigned> {

/// Parse DigitallySigned object, depending on the `ext` parameter which should
/// be true if the TLS client has sent the `signature_algorithms` extension
pub fn parse_content_and_signature<F, T>(
i: &[u8],
pub fn parse_content_and_signature<'a, F, T>(
i: &'a [u8],
fun: F,
ext: bool,
) -> IResult<&[u8], (T, DigitallySigned)>
) -> IResult<&'a [u8], (T, DigitallySigned<'a>)>
where
F: Fn(&[u8]) -> IResult<&[u8], T>,
F: Fn(&'a [u8]) -> IResult<&'a [u8], T>,
{
if ext {
pair(fun, parse_digitally_signed)(i)
Expand Down