[][src]Function asn1_der::der::try_decode_length

pub fn try_decode_length(
    data: &[u8]
) -> Result<Option<(usize, usize)>, Error<Asn1DerError>>

Tries to decode the length of an DER-encoded object

This is especially useful if you don't have access to the full data yet (network-IO etc.) and you want to know how long the payload is.

Parameters:

  • data: The beginning of the DER-encoded stream

Returns:

  • On success:
    • Some((total_length, payload_length)) if the length was decoded successfully
    • None if there is not enough data available yet
  • On error:
    • Asn1DerError::InvalidEncoding if the length-field is invalid
    • Asn1DerError::Unsupported if the length is greater than std::usize::MAX