Open 0x009922 opened 2 months ago
On destructuring and transparent_api
, can we have data model structs with private fields and a pair of (fn from_parts(...) -> Self, fn into_parts(self) -> ...)
for going in and out of the data model context? Even with this, I think that data model types should provide methods instead of relying on something outside using their fields in a correct way. This seems to be related to data model anemia (leaking internals instead of providing the needed functionality through the types).
@nxsaken I think you mean such as described in #4360 ?
This topic was raised many times before, and so I decided to make a dedicated issue for it.
Problems with decomposition
- https://github.com/soramitsu/iroha2-block-explorer-backend/pull/44#issuecomment-2277192800
"Forgetting" to expose some getters
While using
iroha_data_model
crate withouttransparent_api
feature, I repeatedly and very often stumble upon the same issue: some structure doesn't expose getters for its fields, for all or only some of them.This happens because it is done manually in most cases and is not covered by some sort of static check for consistency.
Moreover, in CI
iroha_data_model
seems to always compile withtransparent_api
feature enabled, thus CI doesn't catch even internal possible inconsistencies. For example - #5049:iroha_genesis
usesiroha_data_model
withouttransparent_api
feature enabled while accessing private fields. It works fine in Iroha repository, but doesn't work from the outside.Such things are really minor to fix, but it is too much effort and time to open PRs for each of them. Example of such a PR: #4992
In a sense, I find this "forgetting" issue to be similar to the issue with errors: #4974. Errors are also mostly done manually and mostly never really tested.
Related data-model refactoring issues