I'm creating an app that takes input from a file. The file will be edited by hand and read using toml-rs.
Here is an example:
foo = 7300
bar = "0x4563918244f40000"
This is the struct:
use serde::Deserialize;
use web3::types::U256;
#[derive(Deserialize)]
struct FooBar {
foo: U256,
bar: u32,
}
Here, U256
is a foreign type. It isn't part of my code base.
This works, but there are two problems. First, foo
is scaled quantity. It represents "7.3 percent". Second, bar = "0x4563918244f40000"
is a more than I really want to type.
I would rather do this:
foo = "7.3" # implied conversation
bar = "5.0" # implied conversation
How can this be achieved?