bitcoin-blob 0.1.19

Rust library for defining and manipulating fixed-size opaque byte blobs with serialization, deserialization, hex conversion, and byte iteration capability.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// ---------------- [ File: bitcoin-blob/src/nibble_from_hexchar.rs ]
crate::ix!();

/// Helper: convert a single hex char to nibble
pub fn nibble_from_hexchar(ch: char) -> u8 {
    match ch {
        '0'..='9' => ch as u8 - b'0',
        'a'..='f' => ch as u8 - b'a' + 10,
        'A'..='F' => ch as u8 - b'A' + 10,
        _ => {
            warn!("nibble_from_hexchar => non-hex input char={}", ch);
            0
        }
    }
}