Trait Tokenizer

Source
pub trait Tokenizer {
    // Required methods
    fn tokenize_address(value: &str) -> Result<[u8; 20], Error>;
    fn tokenize_string(value: &str) -> Result<String, Error>;
    fn tokenize_bool(value: &str) -> Result<bool, Error>;
    fn tokenize_bytes(value: &str) -> Result<Vec<u8>, Error>;
    fn tokenize_fixed_bytes(value: &str, len: usize) -> Result<Vec<u8>, Error>;
    fn tokenize_uint(value: &str) -> Result<[u8; 32], Error>;
    fn tokenize_int(value: &str) -> Result<[u8; 32], Error>;

    // Provided methods
    fn tokenize(param: &ParamType, value: &str) -> Result<Token, Error> { ... }
    fn tokenize_fixed_array(
        value: &str,
        param: &ParamType,
        len: usize,
    ) -> Result<Vec<Token>, Error> { ... }
    fn tokenize_struct(
        value: &str,
        param: &[ParamType],
    ) -> Result<Vec<Token>, Error> { ... }
    fn tokenize_array(
        value: &str,
        param: &ParamType,
    ) -> Result<Vec<Token>, Error> { ... }
}
Available on crate feature serde only.
Expand description

This trait should be used to parse string values as tokens.

Required Methods§

Source

fn tokenize_address(value: &str) -> Result<[u8; 20], Error>

Tries to parse a value as an address.

Source

fn tokenize_string(value: &str) -> Result<String, Error>

Tries to parse a value as a string.

Source

fn tokenize_bool(value: &str) -> Result<bool, Error>

Tries to parse a value as a bool.

Source

fn tokenize_bytes(value: &str) -> Result<Vec<u8>, Error>

Tries to parse a value as bytes.

Source

fn tokenize_fixed_bytes(value: &str, len: usize) -> Result<Vec<u8>, Error>

Tries to parse a value as bytes.

Source

fn tokenize_uint(value: &str) -> Result<[u8; 32], Error>

Tries to parse a value as unsigned integer.

Source

fn tokenize_int(value: &str) -> Result<[u8; 32], Error>

Tries to parse a value as signed integer.

Provided Methods§

Source

fn tokenize(param: &ParamType, value: &str) -> Result<Token, Error>

Tries to parse a string as a token of given type.

Source

fn tokenize_fixed_array( value: &str, param: &ParamType, len: usize, ) -> Result<Vec<Token>, Error>

Tries to parse a value as a vector of tokens of fixed size.

Source

fn tokenize_struct( value: &str, param: &[ParamType], ) -> Result<Vec<Token>, Error>

Tried to parse a struct as a vector of tokens

Source

fn tokenize_array(value: &str, param: &ParamType) -> Result<Vec<Token>, Error>

Tries to parse a value as a vector of tokens.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§