Open robfitzgerald opened 1 year ago
You're right that uom
doesn't include units during (de)serialization and because of the generic requirements on fn new
constructing a quantity with a run-time provided unit is not ideal right now. Long term I want to address this issue. Short-term I see a few options, none which are very ideal.
from_str
impl where the unit is provided as a parameter. You would need to manually write out the match
expression but would get the best performance/smallest file.
hi there! thanks for your work.
i want to use uom in code that reads CSVs of velocity data from a user and builds lookup functions from it. i would like to allow the user to specify their velocity unit, but via system configuration instead of inline with every CSV cell, i.e.:
i didn't find any documentation on use of serde with this package to show me how the Type might be parameterized at deserialization, and i did find issues that imply that Units aren't actually reified into enums or structs here to allow matching. i didn't find a function to do this automagically. i tried to build my own enums, which means i have to duplicate the list of supported velocity types, but then i ran into the problem that the return type of my
as_quantity
method below would need to return a specific type argument:wondering if i missed a way to get this kind of behavior, or if using uom i need to 1) require all users specify velocity in one type such as Velocity, 2) require users to append the unit type to every velocity entry in the CSV ("40.2 kph", "41.52 kph" for 55 million rows).
thank you for reading!