Skip to content

Splitting serialization2 into a serializer and deserializer trait #3620

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

Closed
wants to merge 8 commits into from

Conversation

erickt
Copy link
Contributor

@erickt erickt commented Sep 28, 2012

Some types don't make sense to deserialize, such as &str types. This patch moves deserialize out of Serializable into it's own trait, and adds support for the following types:

char
&str
@str
&[T]
@[T]

It also adds an explicit emit_struct and read_struct that passes along the struct name to the Serializer/Deserializer.

It doesn't yet include the "pass-the-serializer-in-a-a-trait-typarm" that @nikomatsakis and I were talking about in IRC, as that seems to trip over an ICE.

It also includes a small patch that renames vec::raw::from_slice into vec::raw::buf_as_slice, which matches str::raw::buf_as_slice and a small bit of cleanup.

@brson
Copy link
Contributor

brson commented Sep 30, 2012

@nikomatsakis Can you review this?

@nikomatsakis
Copy link
Contributor

My impresions: this code looks good, though I think it'd be best if (eventually, perhaps not as part of this pull request) #[auto_serialize] were divided into two annotations: #[auto_serialize] and #[auto_deserialize].

@erickt
Copy link
Contributor Author

erickt commented Oct 1, 2012

I just realized there's a bug. Auto-deserializing a struct still uses d.emit_rec instead of d.emit_struct. I'll upload a fix in a couple minutes. I like #[auto_deserialize], I'll look into it too.

@nikomatsakis
Copy link
Contributor

OK. I tried rebasing this onto incoming and got some merge conflicts.
Didn't look like anything terribly significant. But if you're improving
the patch, I'll hold off on merging it down.

@erickt
Copy link
Contributor Author

erickt commented Oct 1, 2012

Added in my fix, and prepped (but haven't finished yet) support for #[auto_deserialize].

@nikomatsakis
Copy link
Contributor

I'll look at this.

@erickt
Copy link
Contributor Author

erickt commented Oct 1, 2012

Updated to add #[auto_deserialize] and other misc bug fixes.

@nikomatsakis
Copy link
Contributor

Thanks.

bors pushed a commit to rust-lang-ci/rust that referenced this pull request May 15, 2021
RalfJung pushed a commit to RalfJung/rust that referenced this pull request May 19, 2024
test wasm32-wasip2 instead of the deprecated wasm32-wasi target
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