[−][src]Function eosio_numstr::symbol_code_from_bytes
pub fn symbol_code_from_bytes<I>(iter: I) -> Result<u64, ParseSymbolCodeError> where
I: DoubleEndedIterator<Item = u8> + ExactSizeIterator,
Attempts to create an EOSIO symbol from an Iterator
.
Errors
Will return Err
if the symbol contains invalid characters, is too long, or
is empty.
Examples
use eosio_numstr::{symbol_code_from_bytes, ParseSymbolCodeError}; assert_eq!(symbol_code_from_bytes("EOS".bytes()), Ok(5459781)); assert_eq!(symbol_code_from_bytes("TGFT".bytes()), Ok(1413891924)); assert_eq!(symbol_code_from_bytes("SYS".bytes()), Ok(5462355)); assert_eq!( symbol_code_from_bytes("TSt".bytes()), Err(ParseSymbolCodeError::BadChar(b't')) ); assert_eq!( symbol_code_from_bytes("TESTING".bytes()), Ok(20070800200779092) ); assert_eq!( symbol_code_from_bytes("TESTINGG".bytes()), Err(ParseSymbolCodeError::TooLong) );