pub fn config_value_from_json_value(
    val: &JsonValue,
    value_type: &ConfigValueType,
) -> Result<Value, FieldError> {
    Ok(match value_type {
        ConfigValueType::Bool => Value::Single(SingleValue::Flag(val.parse_bool()?)),
        ConfigValueType::Uint8 => Value::Single(SingleValue::Unsigned8(val.parse_u8()?)),
        ConfigValueType::Uint16 => Value::Single(SingleValue::Unsigned16(val.parse_u16()?)),
        ConfigValueType::Uint32 => Value::Single(SingleValue::Unsigned32(val.parse_u32()?)),
        ConfigValueType::Uint64 => Value::Single(SingleValue::Unsigned64(val.parse_u64()?)),
        ConfigValueType::Int8 => Value::Single(SingleValue::Signed8(val.parse_i8()?)),
        ConfigValueType::Int16 => Value::Single(SingleValue::Signed16(val.parse_i16()?)),
        ConfigValueType::Int32 => Value::Single(SingleValue::Signed32(val.parse_i32()?)),
        ConfigValueType::Int64 => Value::Single(SingleValue::Signed64(val.parse_i64()?)),
        ConfigValueType::String { max_size } => {
            Value::Single(SingleValue::Text(val.parse_string(*max_size)?))
        }
        ConfigValueType::Vector { max_count, nested_type } => {
            Value::List(list_value_from_json(val, max_count, nested_type)?)
        }
    })
}
/// Returns a FIDL value to encode in the file for the provided JSON value, if and only if the value
/// matches the type from the declaration.
Returns a FIDL value to encode in the file for the provided JSON value, if and only if the value
matches the type from the declaration.
Returns a FIDL value to encode in the file for the provided JSON value if and only if the value matches the type from the declaration .
pub fn config_value_from_json_value(
    val: &JsonValue,
    value_type: &ConfigValueType,
) -> Result<Value, FieldError> {
    Ok(match value_type {
        ConfigValueType::Bool => Value::Single(SingleValue::Flag(val.parse_bool()?)),
        ConfigValueType::Uint8 => Value::Single(SingleValue::Unsigned8(val.parse_u8()?)),
        ConfigValueType::Uint16 => Value::Single(SingleValue::Unsigned16(val.parse_u16()?)),
        ConfigValueType::Uint32 => Value::Single(SingleValue::Unsigned32(val.parse_u32()?)),
        ConfigValueType::Uint64 => Value::Single(SingleValue::Unsigned64(val.parse_u64()?)),
        ConfigValueType::Int8 => Value::Single(SingleValue::Signed8(val.parse_i8()?)),
        ConfigValueType::Int16 => Value::Single(SingleValue::Signed16(val.parse_i16()?)),
        ConfigValueType::Int32 => Value::Single(SingleValue::Signed32(val.parse_i32()?)),
        ConfigValueType::Int64 => Value::Single(SingleValue::Signed64(val.parse_i64()?)),
        ConfigValueType::String { max_size } => {
            Value::Single(SingleValue::Text(val.parse_string(*max_size)?))
        }
        ConfigValueType::Vector { max_count, nested_type } => {
            Value::List(list_value_from_json(val, max_count, nested_type)?)
        }
    })
}
pub fn config_value_from_json_value ( val : & JsonValue , value_type : & ConfigValueType , ) -> Result < Value , FieldError > { Ok ( match value_type { ConfigValueType :: Bool => Value :: Single ( SingleValue :: Flag ( val . parse_bool ( ) ? ) ) , ConfigValueType :: Uint8 => Value :: Single ( SingleValue :: Unsigned8 ( val . parse_u8 ( ) ? ) ) , ConfigValueType :: Uint16 => Value :: Single ( SingleValue :: Unsigned16 ( val . parse_u16 ( ) ? ) ) , ConfigValueType :: Uint32 => Value :: Single ( SingleValue :: Unsigned32 ( val . parse_u32 ( ) ? ) ) , ConfigValueType :: Uint64 => Value :: Single ( SingleValue :: Unsigned64 ( val . parse_u64 ( ) ? ) ) , ConfigValueType :: Int8 => Value :: Single ( SingleValue :: Signed8 ( val . parse_i8 ( ) ? ) ) , ConfigValueType :: Int16 => Value :: Single ( SingleValue :: Signed16 ( val . parse_i16 ( ) ? ) ) , ConfigValueType :: Int32 => Value :: Single ( SingleValue :: Signed32 ( val . parse_i32 ( ) ? ) ) , ConfigValueType :: Int64 => Value :: Single ( SingleValue :: Signed64 ( val . parse_i64 ( ) ? ) ) , ConfigValueType :: String { max_size } => { Value :: Single ( SingleValue :: Text ( val . parse_string ( * max_size ) ? ) ) } ConfigValueType :: Vector { max_count , nested_type } => { Value :: List ( list_value_from_json ( val , max_count , nested_type ) ? ) } } ) }
Returns a FIDL value to encode in the file for the provided JSON value, if and only if the value
matches the type from the declaration.
Returns a FIDL value to encode in the file for the provided JSON value if and only if the value matches the type from the declaration .
val
&JsonValue
value_type
&ConfigValueType
val
&JsonValue
value_type
&ConfigValueType