[−][src]Function eosio_numstr::symbol_from_bytes
pub fn symbol_from_bytes<I>(
precision: u8,
iter: I
) -> Result<u64, ParseSymbolError> 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_from_bytes, ParseSymbolError}; assert_eq!(symbol_from_bytes(4, "EOS".bytes()), Ok(1397703940)); assert_eq!(symbol_from_bytes(0, "TGFT".bytes()), Ok(361956332544)); assert_eq!(symbol_from_bytes(2, "SYS".bytes()), Ok(1398362882)); assert_eq!( symbol_from_bytes(4, "TSt".bytes()), Err(ParseSymbolError::BadChar(b't')) ); assert_eq!( symbol_from_bytes(0, "TESTING".bytes()), Ok(5138124851399447552) ); assert_eq!( symbol_from_bytes(0, "TESTINGG".bytes()), Err(ParseSymbolError::CodeTooLong) );