parse_value

Function parse_value 

Source
pub fn parse_value(value: &str) -> Result<U256>
Expand description

Parse a value string as U256, supporting both decimal and hexadecimal formats

This function attempts to parse the value as decimal first, then as hexadecimal (with optional “0x” prefix) if decimal parsing fails.

§Arguments

  • value - The string value to parse

§Returns

  • Ok(U256) - The parsed value
  • Err(OdosError) - If the value cannot be parsed in either format

§Examples

// Decimal format
let val = parse_value("1000")?;
assert_eq!(val, U256::from(1000));

// Hexadecimal with 0x prefix
let val = parse_value("0xff")?;
assert_eq!(val, U256::from(255));

// Hexadecimal without prefix
let val = parse_value("ff")?;
assert_eq!(val, U256::from(255));