pub fn decode_hexbytes(hexbytes: &Vec<u8>) -> Result<Vec<u8>, &'static str> {

    let hex_values: Vec<u8> = hexbytes.iter()
                        .map(|&x| decode_hexbyte(x).unwrap())
                        .collect();
    let mut bytes: Vec<u8> = Vec::new();
    for i in (0..hex_values.len() - 1).filter(|&x| x % 2 == 0) {
        bytes.push((hex_values[i] * 0x10) + hex_values[i+1]);
    }
    Ok(bytes)
}
/// Decodes a hexadecimal representation of a string
/// TODO implement better error handling
Decodes a hexadecimal representation of a string
TODO implement better error handling
Decodes a hexadecimal representation of a string TODO implement better error handling
pub fn decode_hexbytes(hexbytes: &Vec<u8>) -> Result<Vec<u8>, &'static str> {
    let hex_values: Vec<u8> = hexbytes.iter()
                        .map(|&x| decode_hexbyte(x).unwrap())
                        .collect();
    let mut bytes: Vec<u8> = Vec::new();
    for i in (0..hex_values.len() - 1).filter(|&x| x % 2 == 0) {
        bytes.push((hex_values[i] * 0x10) + hex_values[i+1]);
    }
    Ok(bytes)
}
pub fn decode_hexbytes ( hexbytes : & Vec < u8 > ) -> Result < Vec < u8 > , & ' static str > { let hex_values : Vec < u8 > = hexbytes . iter ( ) . map ( | & x | decode_hexbyte ( x ) . unwrap ( ) ) . collect ( ) ; let mut bytes : Vec < u8 > = Vec :: new ( ) ; for i in ( 0 .. hex_values . len ( ) - 1 ) . filter ( | & x | x % 2 == 0 ) { bytes . push ( ( hex_values [ i ] * 0x10 ) + hex_values [ i + 1 ] ) ; } Ok ( bytes ) }
Decodes a hexadecimal representation of a string
TODO implement better error handling
Decodes a hexadecimal representation of a string TODO implement better error handling
hexbytes
&Vec<u8>
hexbytes
&Vec<u8>