Skip to main content

bytes_to_u128

Function bytes_to_u128 

Source
pub fn bytes_to_u128(bytes: &[u8]) -> Result<u128>
Expand description

Converts bytes to a u128 value.

§Arguments

  • bytes - Exactly 16 bytes to convert

§Returns

The u128 value, or an error if the input length is wrong.

§Errors

Returns Error::InvalidLength if bytes is not exactly 16 bytes.

§Example

use stealth_lib::encoding::hex_utils::bytes_to_u128;

let bytes = [0u8; 16];
let value = bytes_to_u128(&bytes).unwrap();
assert_eq!(value, 0);