When defining mapping struct to diesel table!, it’s recommended to use non-public field.
What’s the influence if use public field in a struct for mapping, or whether it’s legal to use pub field?
Where did you get that information from? It’s purely a decision of whoever implements the mapping if a certain field is public or not. Diesel does not depend on certain fields being (non)public.
It’s only my observation from diesel docs, nobody ever told me that. Recently I want to convert from mapping struct into another relatively handy struct because mapping struct design is constraint by SQLite database backend. If so, make field public in mapping struct would help a lot for convertion.
Please keep in mind that the examples for the documentation are minimalistic. They are not supposed to interact with every rust language feature available, but they are designed to show just the according feature of diesel.
Diesel offers several options to do such things while deserializing data coming from the database. Checkout the documentation for Queryable
for details.
Thanks for considerate answer. I am keeping eye on it.