An SDK generated with publicConstrainedTypes set to false does not compile and raises the following error:
error[E0277]: the trait bound `HashMap<std::string::String, Vec<Vec<std::string::String>>>: From<ItemMap>` is not satisfied
--> src/input.rs:136:55
This error occurs because SampleOpInput is defined as a HashMap with String as the key:
pub struct SampleOpInput {
#[allow(missing_docs)] // documentation missing in model
pub items: ::std::option::Option<
::std::collections::HashMap<
::std::string::String,
::std::vec::Vec<::std::vec::Vec<::std::string::String>>,
>,
>,
}
The method build_enforcing_all_constraints attempts to construct SampleOpInput by invoking the From implementation for ItemMap. However, the generated implementation uses ItemName (not String) as the key type for the HashMap:
impl ::std::convert::From<ItemMap>
for ::std::collections::HashMap<
crate::model::ItemName,
::std::vec::Vec<::std::vec::Vec<::std::string::String>>,
>
An additional From<ItemMap> needs to be generated:
93 | value.into_inner().into_iter().map(|v| v.into()).collect()
| ^^^^ the trait `From<HashMap<ItemName, std::string::String>>` is not implemented for `HashMap<std::string::String, std::string::String>`, which is required by `HashMap<ItemName, std::string::String>: Into<_>`
Missing
From
ImplementationConsider the following model:
An SDK generated with
publicConstrainedTypes
set tofalse
does not compile and raises the following error:This error occurs because
SampleOpInput
is defined as aHashMap
withString
as the key:The method
build_enforcing_all_constraints
attempts to constructSampleOpInput
by invoking theFrom
implementation forItemMap
. However, the generated implementation usesItemName
(notString
) as the key type for theHashMap
:An additional
From<ItemMap>
needs to be generated:A directly constrained list with indirectly constrained map
Consider the following model:
This results in non-compilable code:
This happens because
ItemList
is defined as:Where as the
TryFrom
implementation assumes that theHashMap
hasString
as key instead ofItemName
:Constrained map with a non-constrained list that has a constrained list as member
Results in a compilation error on
v.into()
in the followingFrom<ItemMap>
implementation:Nested lists
Results in an error in
TryFrom<ItemsList>
implementation atv.into()
.