Function parse_query_return_string_data

Source
pub fn parse_query_return_string_data<T: NativeConvertible + TopDecodeMulti>(
    data: &[&str],
) -> Result<T, DataError>
Expand description

Parses and decodes a slice of base64-encoded strings obtained from a blockchain gateway query, or a mocked environment, into a native Rust type.

This function first decodes the base64-encoded strings into bytes, then delegates the parsing of the byte data to parse_query_return_bytes_data.

§Type Parameters

  • T: The native Rust type to which the data should be parsed, which must implement both NativeConvertible and TopDecodeMulti traits.

§Parameters

  • data: A slice of base64-encoded strings representing the data to be parsed.

§Returns

A Result containing the parsed native type, or a DataError if parsing fails.

§Examples

let data = vec!["AhhxGgA="];
let result: Result<u64, DataError> = parse_query_return_string_data(&data);

assert_eq!(result.unwrap(), 9000000000_u64)