Skip to content

Using #[serde_as] with custom (de-)serialize functions #225

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

You must be logged in to vote

Hi @Lehona,

I agree that documentation can be improved by a lot. So far this crate doesn't have many users, so I don't know where the hurdles are which need documenting. I don't know if the usage can ever be quite as simple as writing a module with a serialize and a deserialize function, since serde_as works by building a specific type "tree" and uses that to guide the de-/serialization. I see how I can document the interaction better though.

Coming back to your question though. I think there is no problem in supporting a foreign type, only a bit of boilerplate. I just focus on the SerializeAs trait for now, but the same applies to DeserializeAs. The trait works in reverse, which allows y…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by jonasbb
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
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
Converted from issue

This discussion was converted from issue #225 on December 16, 2020 20:12.