taos_query/util/
hex.rs

1use bytes::Bytes;
2
3pub fn hex_string_to_bytes(s: &str) -> Bytes {
4    let b: Vec<u8> = s
5        .as_bytes()
6        .chunks(2)
7        .map(|chunk| std::str::from_utf8(chunk).unwrap())
8        .map(|chunk| u8::from_str_radix(chunk, 16).unwrap())
9        .collect();
10    Bytes::from(b)
11}
12
13#[test]
14fn test_inline_lines() {
15    assert_eq!(
16        Bytes::from(vec![0x12, 0x34, 0x56]),
17        hex_string_to_bytes("123456")
18    );
19}