Closed MathisWellmann closed 1 year ago
Thx for the PR. Unfortunately, Decimal is using an i128 integer for the coefficient and serde doesn't seem to support integers larger than 64-bit out of the box. I'll have to dig into serde to find a solution.
After some re-thinking, I will not directly serialize or deserialize the Decimal
type as its rather confusing from a user-facing perspective to have to specify the inner fields. Consider this PR low priority or feel free to close it as well.
Cheers!
I've created a branch 'serde'. The feature 'serde_as_str' allows Decimal instances to be serialized to / deserialized from String. Maybe you want to give it a try. If so, please let me know what you think about it.
Just tried out your new feature branch and it looks excellent.
Using the From<Decimal>
and TryFrom<String>
trait implementations through the serde features is a fantastic way, especially from the users perspective (As they should not be bothered to specify the coeff).
Having to enable both serde
and serde_as_str
features is the right choice as well, as not everyone will want to use String
as the intermediate representation.
Integrating the feature is straightforward as well.
I certainly would be happy seeing these changes in a crates.io
release.
Gute Arbeit :)
Solved by adding feature 'serde-as-str'. See version 0.6.0.
to allow serialization and deserialization of the
Decimal
struct. It only takes effect if the dependency is specified as such:The reason for this addition is that I would like to be able to rely on serde support in
lfest
to serialize theBaseCurrency
andQuoteCurrency
among others. I would love to see this change get merged and published so a new version oflfest
can be published as well.Thank you for such an amazing crate, I'm glad I found it!