pub fn write_multihash(
  w: &mut ByteCursor,
  code: u64,
  size: u8,
  digest: &[u8],
) -> Result<(), Error> {
  let mut code_buf = varint_encode::u64_buffer();
  let code = varint_encode::u64(code, &mut code_buf);

  let mut size_buf = varint_encode::u8_buffer();
  let size = varint_encode::u8(size, &mut size_buf);

  match w.write_all(code) {
    Ok(_) => (),
    Err(_) => return Err(Error::Varint(decode::Error::Overflow)),
  };
  match w.write_all(size) {
    Ok(_) => (),
    Err(_) => return Err(Error::Varint(decode::Error::Overflow)),
  };
  match w.write_all(digest) {
    Ok(_) => (),
    Err(_) => return Err(Error::Varint(decode::Error::Overflow)),
  };
  w.set_position(0);
  Ok(())
}
/// Writes the multihash to a byte stream.
Writes the multihash to a byte stream.
Writes the multihash to a byte stream .
pub fn write_multihash(
  w: &mut ByteCursor,
  code: u64,
  size: u8,
  digest: &[u8],
) -> Result<(), Error> {
  let mut code_buf = varint_encode::u64_buffer();
  let code = varint_encode::u64(code, &mut code_buf);
  let mut size_buf = varint_encode::u8_buffer();
  let size = varint_encode::u8(size, &mut size_buf);
  match w.write_all(code) {
    Ok(_) => (),
    Err(_) => return Err(Error::Varint(decode::Error::Overflow)),
  };
  match w.write_all(size) {
    Ok(_) => (),
    Err(_) => return Err(Error::Varint(decode::Error::Overflow)),
  };
  match w.write_all(digest) {
    Ok(_) => (),
    Err(_) => return Err(Error::Varint(decode::Error::Overflow)),
  };
  w.set_position(0);
  Ok(())
}
pub fn write_multihash ( w : & mut ByteCursor , code : u64 , size : u8 , digest : & [ u8 ] , ) -> Result < ( ) , Error > { let mut code_buf = varint_encode :: u64_buffer ( ) ; let code = varint_encode :: u64 ( code , & mut code_buf ) ; let mut size_buf = varint_encode :: u8_buffer ( ) ; let size = varint_encode :: u8 ( size , & mut size_buf ) ; match w . write_all ( code ) { Ok ( _ ) => ( ) , Err ( _ ) => return Err ( Error :: Varint ( decode :: Error :: Overflow ) ) , } ; match w . write_all ( size ) { Ok ( _ ) => ( ) , Err ( _ ) => return Err ( Error :: Varint ( decode :: Error :: Overflow ) ) , } ; match w . write_all ( digest ) { Ok ( _ ) => ( ) , Err ( _ ) => return Err ( Error :: Varint ( decode :: Error :: Overflow ) ) , } ; w . set_position ( 0 ) ; Ok ( ( ) ) }
Writes the multihash to a byte stream.
Writes the multihash to a byte stream .
w
&mut ByteCursor
code
u64
size
u8
digest
&[u8]
w
&mut ByteCursor
code
u64
size
u8
digest
&[u8]