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

MessagePack support #96

Closed
3Hren opened this issue Jul 1, 2015 · 13 comments
Closed

MessagePack support #96

3Hren opened this issue Jul 1, 2015 · 13 comments
Labels

Comments

@3Hren
Copy link
Contributor

3Hren commented Jul 1, 2015

Does anyone need MessagePack support?

I can implement it in https://github.com/3Hren/msgpack-rust as an option.

It's not an issue actually, but it may generate issues if I start to working with it :)

@erickt
Copy link
Member

erickt commented Jul 12, 2015

That would be wonderful! If you haven't starting working on it yet, I think I have a partially implemented version I started and didn't finish months ago.

@dswd
Copy link
Contributor

dswd commented Jul 17, 2015

I am working on that. It seems to work pretty well except for enums which are very complicated as each variant can have a different type. How should I publish the code?
Should I make a separate crate or should I create a pull request?
BTW: I also have some macros which allow to serialize structs to tuples and maps without using a compiler plugin.

@3Hren
Copy link
Contributor Author

3Hren commented Jul 17, 2015

Actually I've already have rustc_serialize support in RMP: https://github.com/3Hren/msgpack-rust/blob/master/src/decode.rs#L1754.
Migrating from it to serde doesn't seems like a big problem.

The real challenge - is to how implement zero-copy deserialization into a non-owning structs, which contains &str or &[T] for example. Does serde allows to do that somehow?

Personally I want to make RMP the main Rust MessagePack library.

PR is ok if only serde plans to be the main serialization/deserialization library for Rust (and rustc_serialize is going to be dead, right?). Otherwise the separate crate is the only meaningful option.

@dswd
Copy link
Contributor

dswd commented Jul 17, 2015

My main problem with rmp, mpack and msgpack was that neither of them allowed me to serialize [u8] to msgpack bin. Instead all rustc-serialize based serializers serialize [u8] as a list of single u8 which is very inefficient as half of those bytes require two bytes to serialize.

@3Hren
Copy link
Contributor Author

3Hren commented Jul 17, 2015

Wrong: https://github.com/3Hren/msgpack-rust/blob/master/src/encode.rs#L646

Oops, it's private right now :( I'll make an update ASAP.

UPD: If you have problems with RMP you should definitely create an issue :)
UPD2: Done: v0.4.0. You're welcome.

@dswd
Copy link
Contributor

dswd commented Jul 17, 2015

Yes, you are right. However I did not figure out any way to use that with rustc-serialize.

@3Hren
Copy link
Contributor Author

3Hren commented Jul 17, 2015

With rustc_serialize - you're right, it's impossible. Does serde allows to encode &[u8] directly?

@dswd
Copy link
Contributor

dswd commented Jul 17, 2015

Not exactly but there is a wrapper type Bytes which serializes to bin. I don't think such a wrapper type would be possible with rustc_serialize as it does not expose any way to serialize binary data through its API.

@erickt
Copy link
Member

erickt commented Aug 10, 2015

@3Hren and @dswd: I've also hacked up msgpack support in 3Hren/msgpack-rust#26.

@erickt
Copy link
Member

erickt commented Aug 11, 2015

This has landed in rmp!

@erickt erickt closed this as completed Aug 11, 2015
@dswd
Copy link
Contributor

dswd commented Aug 12, 2015

I don't see how this improves on the &[u8] issue. As far as I can see rmp still does not support it. There is no way to serialize something to binary data and you get a type mismatch error if you try to deserialize it.

@3Hren
Copy link
Contributor Author

3Hren commented Aug 12, 2015

Does this help with deserializing: 3Hren/msgpack-rust@380a68b?

@3Hren
Copy link
Contributor Author

3Hren commented Aug 12, 2015

And this should help with serialization: 3Hren/msgpack-rust@6c1f7c1

@dtolnay dtolnay added the format label May 14, 2016
rubdos pushed a commit to rubdos/serde that referenced this issue Jun 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants