from_hex
fn from_hex(string s) -> Result<Vec<byte>, string> Import
Source: use bytes::{from_hex}; src/bytes.hy Decodes hexadecimal text (either case) into bytes.
Parameters#
| Name | Type |
|---|---|
s | string |
Returns#
Result<Vec<byte>, string>
Errors#
Returns Err when s has an odd length or a character that is not a hex digit.
Examples#
use bytes::{from_hex};
use tests::assert;
let b = from_hex("00AbfF") ?? Vec::new();
assert!(b.len() == 3 && b[1] == 171 as byte);
assert!(from_hex("abc").is_err());
See also#
region_eq: True whena[ao..ao+n)equalsb[bo..bo+n)(caller guarantees bounds).to_hex: Encodesbufas lowercase hexadecimal, two digits per byte.slice: Returns a copy ofsrc[start..end](end exclusive), with both offsets clamped to the buffer.concat: Returns a new buffer holdingafollowed byb.eq: Returnstruewhenaandbhave the same length and the same bytes.find_from: Returns the offset of the firstneedleinhayat or afterstart, or-1.find: Returns the offset of the firstneedleinhay, or-1.rfind: Returns the offset of the lastneedleinhay, or-1.