pub fn read_multihash<const S: usize>(
  r: &mut ByteCursor,
) -> Result<(u64, u8, [u8; S]), Error> {
  let code = match read_u64(r) {
    Ok(c) => c,
    Err(e) => return Err(e),
  };
  let size = match read_u64(r) {
    Ok(s) => s,
    Err(e) => return Err(e),
  };

  if size > S.try_into().unwrap() || size > u8::MAX as u64 {
    return Err(Error::InvalidSize(size));
  }

  let mut digest = [0; S];

  match r.read_exact(&mut digest[..size as usize]) {
    Ok(_) => (),
    Err(_) => return Err(Error::Varint(decode::Error::Overflow)),
  }
  Ok((code, size as u8, digest))
}
/// Reads a multihash from a byte stream that contains a full multihash (code,
/// size and the digest)
///
/// Returns the code, size and the digest. The size is the actual size and not
/// the maximum/allocated size of the digest.
///
/// Currently the maximum size for a digest is 255 bytes.
Reads a multihash from a byte stream that contains a full multihash (code,
size and the digest)

Returns the code, size and the digest. The size is the actual size and not
the maximum/allocated size of the digest.

Currently the maximum size for a digest is 255 bytes.
Reads a multihash from a byte stream that contains a full multihash ( code size and the digest ) Returns the code size and the digest . The size is the actual size and not the maximum / allocated size of the digest . Currently the maximum size for a digest is 255 bytes .
pub fn read_multihash<const S: usize>(
  r: &mut ByteCursor,
) -> Result<(u64, u8, [u8; S]), Error> {
  let code = match read_u64(r) {
    Ok(c) => c,
    Err(e) => return Err(e),
  };
  let size = match read_u64(r) {
    Ok(s) => s,
    Err(e) => return Err(e),
  };
  if size > S.try_into().unwrap() || size > u8::MAX as u64 {
    return Err(Error::InvalidSize(size));
  }
  let mut digest = [0; S];
  match r.read_exact(&mut digest[..size as usize]) {
    Ok(_) => (),
    Err(_) => return Err(Error::Varint(decode::Error::Overflow)),
  }
  Ok((code, size as u8, digest))
}
pub fn read_multihash < const S : usize > ( r : & mut ByteCursor , ) -> Result < ( u64 , u8 , [ u8 ; S ] ) , Error > { let code = match read_u64 ( r ) { Ok ( c ) => c , Err ( e ) => return Err ( e ) , } ; let size = match read_u64 ( r ) { Ok ( s ) => s , Err ( e ) => return Err ( e ) , } ; if size > S . try_into ( ) . unwrap ( ) || size > u8 :: MAX as u64 { return Err ( Error :: InvalidSize ( size ) ) ; } let mut digest = [ 0 ; S ] ; match r . read_exact ( & mut digest [ .. size as usize ] ) { Ok ( _ ) => ( ) , Err ( _ ) => return Err ( Error :: Varint ( decode :: Error :: Overflow ) ) , } Ok ( ( code , size as u8 , digest ) ) }
Reads a multihash from a byte stream that contains a full multihash (code,
size and the digest)
Reads a multihash from a byte stream that contains a full multihash ( code size and the digest )
r
&mut ByteCursor
r
&mut ByteCursor