Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement serde::Serialize for Config #508

Open
nectariner opened this issue Dec 19, 2023 · 3 comments
Open

Implement serde::Serialize for Config #508

nectariner opened this issue Dec 19, 2023 · 3 comments

Comments

@nectariner
Copy link

I want to be able to serialize my config to json so that when I log it Cloudwatch formats it correctly. I'm not aware of another simple way of doing this, it's unfortunate since the regular debug output is so close to what I need but Cloudwatch formats it horribly since it's not actual json

@matthiasbeyer
Copy link
Collaborator

You can use Config::try_deserialize() to deserialize config to your own type and have that implement Serialize!

@nectariner
Copy link
Author

Apologies if this is a stupid question (I'm not familiar with the codebase whatsoever) - is there a reason why it couldn't implement Serialize itself?

@matthiasbeyer
Copy link
Collaborator

Hm, I don't know to be honest. One thing I could imagine is that serializing does more than just "dumping the data to some format", but actually includes logic that is a bit more on the heavy side of things? Like... it actually has to compute stuff to be even able to provide the data that is needed for the serialization, and because of that implementing Serialize directly would give a user a false sense of "cost" for this functionality?

But to be honest, I don't really know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants