pub fn parse_token(bytes: &[u8]) -> Result<DynToken, DynError>Expand description
Parse a textual token from bytes. Accepts an optional leading -,
then base-10 digits.
§Errors
Returns DynError::Generic when the input is empty, contains
non-digit bytes, or specifies a length that overflows the token.
§Examples
use dynomite::hashkit::token::{parse_token, Sign};
let t = parse_token(b"42").unwrap();
assert_eq!(t.sign(), Sign::Positive);
assert_eq!(t.get_int(), 42);
assert!(parse_token(b"").is_err());