Skip to content

How to mix serde with = and serde_as rules? / u128 as Hex #507

Answered by jonasbb
steinerkelvin asked this question in Q&A
Discussion options

You must be logged in to vote

I am unsure what exactly you think the u128_as_buffer should be doing. But I am not aware of any way of chaining multiple functions. The serde_as macro will also not let you use as and with on the same field.

In your case, your module will need to do everything, i.e., turn the u128 into a hex value and then instruct the Serializer how to serialize it. Of course it is also possible to use the SerializeAs trait from this crate, i.e., you can make a type similar to Hex which supports u128.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@steinerkelvin
Comment options

@jonasbb
Comment options

Answer selected by steinerkelvin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants