array-bytes
A Collection of Array/Bytes/Hex Utilities.
Abilities
TryFromHex trait
- Convert
HextoNum- type
&str -> isize - type
&str -> i8 - type
&str -> i16 - type
&str -> i32 - type
&str -> i64 - type
&str -> i128 - type
&str -> usize - type
&str -> u8 - type
&str -> u16 - type
&str -> u32 - type
&str -> u64 - type
&str -> u128
- type
bytes prefixed functions
- Convert
BytestoHex- type
&[u8] -> String
- type
hex prefixed functions
- Convert
HexBytestoHex- type
&[u8] -> &str - e.g.
b"0x..." -> "0x..."
- type
- Build fixed length
ArrayfromHex- type
&str -> [u8; N]
- type
- Convert
HextoBytes- type
&str -> Vec<u8>
- type
- Transform
HextoT- type
&str -> T - e.g.
"0x..." -> [u8; 20] -> H160
- type
slice prefixed functions
- Build fixed length
ArrayfromSlice- type
&[T] -> [T; N]
- type
- Transform
SlicetoG- type
&[T] -> G - e.g.
&[0_u8, ...] -> [u8; 20] -> H160
- type
vec prefixed functions
- Build fixed length
ArrayfromVec- type
Vec<T> -> [T; N]
- type
- Transform
VectoG- type
Vec<T> -> G - e.g.
vec![0_u8, ...] -> [u8; 20] -> H160
- type
Serde support (require feature serde)
#[serde(deserialize_with = "array_bytes::hex_deserialize_n_into")]- type
S -> T - e.g.
"0x..." -> H160
- type
#[serde(deserialize_with = "array_bytes::de_hex2num")]- type
S -> Num - e.g.
"0xA" -> 10_u32
- type
#[serde(deserialize_with = "array_bytes::de_hex2bytes")]- type
S -> Vec<u8> - e.g.
"0x00" -> vec![0_u8]
- type
Benchmark results
bytes2hex time:
change:
Change within noise threshold.
encode time:
change:
No change in performance detected.
Found 1 outliers among 100 measurements
1 low mild
to_hex time:
change:
Change within noise threshold.
Found 10 outliers among 100 measurements
10 low mild
hex_string time:
change:
Performance has regressed.
Found 14 outliers among 100 measurements
5 low severe
5 low mild
1 high mild
3 high severe
hex_encode_fallback
time:
change:
Performance has regressed.
Found 2 outliers among 100 measurements
2 low mild
hex2bytes time:
change:
Change within noise threshold.
Found 6 outliers among 100 measurements
5 low mild
1 high severe
hex2bytes_unchecked
time:
change:
No change in performance detected.
Found 6 outliers among 100 measurements
2 low severe
4 low mild
decode time:
change:
Change within noise threshold.
Found 2 outliers among 100 measurements
1 low mild
1 high mild
from_hex time:
change:
No change in performance detected.
Found 9 outliers among 100 measurements
1 low severe
2 low mild
4 high mild
2 high severe
hex_decode time:
change:
Performance has improved.
Found 7 outliers among 100 measurements
2 low mild
2 high mild
3 high severe
hex_decode_unchecked
time:
change:
No change in performance detected.
Found 5 outliers among 100 measurements
1 low mild
3 high mild
1 high severe
hex_decode_fallback
time:
change:
Change within noise threshold.
Found 4 outliers among 100 measurements
4 high mild
License
Licensed under either of Apache-2.0 or GPL-3.0 at your option.