Convert encodable()
methods to From
implementations
#3124
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Our JSON
views
and the databasemodels
are currently tightly coupled through theencodable()
methods on almost all models.Instead of having the database models depend on the JSON views it would be better to reverse this relationship, so that the database models can live on their own, and only the JSON views are depending on the database models. This would eventually allow us to extract the database models and schema into a dedicated crate, which would then allow us to cut down the dependency tree of some second-level binaries like
monitor
andbackground-worker
This PR starts the process of moving away from
encodable()
by implementing theFrom
trait for two of our JSON views. This allows us to call.into()
on the models to automatically convert it to the JSON view form.r? @pietroalbini