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

Fix #89: #[derive(Schema)] for StructVariants #134

Merged
merged 7 commits into from
May 13, 2024
Merged

Fix #89: #[derive(Schema)] for StructVariants #134

merged 7 commits into from
May 13, 2024

Conversation

barafael
Copy link
Contributor

@barafael barafael commented Apr 1, 2024

Here comes a 4-commit sandwich.

The actual issue I believe is fixed with this. However, there are 2 open questions regarding the schema tests (see commit message bodies):

  • Where should the schema tests be located? As of now, they force the schema module to be public because they are integration tests. A doc comment above mod schema; explicitly says not to make experimental features pub 😆
  • The test for struct serialization does not pass. It seems it wants the array member to be schematized as a Seq, but the array member is schematized as a 10-element Tuple.

Let me know what you think :) I love using this crate.

It seems they were guarded under an invalid feature name.
Also, they are located with the integration tests for postcard, but the schema module is not publicly visible, so they don't compile.
I switched it to public (for now).
Not sure if the test was wrong or the serialization is wrong.
For now, I'm after #89, so I'll just make the test green to see if my changes break anything.
A satisfying one-char fix :)
Copy link

netlify bot commented Apr 1, 2024

Deploy Preview for cute-starship-2d9c9b canceled.

Name Link
🔨 Latest commit 6906f4b
🔍 Latest deploy log https://app.netlify.com/sites/cute-starship-2d9c9b/deploys/66421acdcd942c0008f6de3f

@jamesmunns
Copy link
Owner

Hey @barafael, overall looks good!

  1. can we use the scoped/conditional exports, e.g. postcard::experimental::schema instead of making postcard::schema public? If not, could you please slap it with a #[doc(hidden)] and a comment that says "this isn't API stable, just an impl detail"?
  2. Re: 5d0e703, I dunno, I'll have to look, that looks very seq-y to me.

Thanks!

@barafael
Copy link
Contributor Author

barafael commented Apr 7, 2024

1.: maybe a simple conditional pub is good enough?

@barafael
Copy link
Contributor Author

Re: 2, not sure what to do about it, @jamesmunns could you have a look?

@jamesmunns
Copy link
Owner

@barafael I fixed some merge conflicts, and looked at the test.

I believe the test as-is now is correct: fixed size arrays, such as [T; N], should be serialized as tuples, as the length is known, so the length is not sent on the wire. Slices (and Vecs) such as &[T] should be serialized as Seqs, as their length WILL be sent on the wire.

Thank you!

@jamesmunns jamesmunns merged commit 42317d9 into jamesmunns:main May 13, 2024
4 checks passed
@ia0 ia0 mentioned this pull request May 13, 2024
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.

2 participants