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

Add support for skipped fields #174

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dns2utf8
Copy link

@dns2utf8 dns2utf8 commented Sep 17, 2024

Hi all

I made this PR to support maybe skipped fields, either always or dynamically with #[serde(skip_serializing_if = "Option::is_none")].

I have considered hiding the function behind a feature flag and adding a runtime Err without the flag so consumers of the crate notice that they were trying to serialize an object that would not be readable again.

Looking forward hearing from you,
Stefan

PS: I assume that None::<()> takes the same amount of space as None::<u128> or something else would and that trick then allows us to stay with the wire format, 99% sure of that, happy to learn 😊

Copy link

netlify bot commented Sep 17, 2024

Deploy Preview for cute-starship-2d9c9b canceled.

Name Link
🔨 Latest commit 8a4e39f
🔍 Latest deploy log https://app.netlify.com/sites/cute-starship-2d9c9b/deploys/66e9ef813065fd000860938f

@ManevilleF
Copy link

Does this also fix the #[serde(skip)] attribute ? or is it only targetted to skip_serializing_if ?

@dns2utf8-novaziun
Copy link

It works with skip, but it serialized it to a None, so I am not sure what happens if your type is not Option<T>

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

Successfully merging this pull request may close these issues.

3 participants