0

I have a struct like this

struct A {
  id: i8,
  key: i16,
  name: String,
  values: Vec<String>
}

I wish to convert it to bytes and pad it with the converted size so I can send it over TCP. The string data should be sent as itself. I will worry about the endianness of things once this part is done.

I am using rustc 1.0.0-beta.3 (5241bf9c3 2015-04-25) (built 2015-04-25). I looked at How to convert 'struct' to '&[u8]'?, but bincode is having compilation problems with the beta. I am hoping to find a non-external lib way for doing the above.

Community
  • 1
  • 1
spicavigo
  • 4,116
  • 22
  • 28
  • 1
    You could also try CBOR: https://github.com/BurntSushi/rust-cbor – BurntSushi5 Apr 30 '15 at 01:54
  • *but bincode is having compilation problems with the beta* - it does compile successfully on my nightly version. Don't have the beta handy to test with. – Shepmaster Apr 30 '15 at 01:58
  • Thanks @Shepmaster. I will use nightly then. Everything is a moving target right now, so why not work with nightly. – spicavigo Apr 30 '15 at 02:01
  • Well, things *should* be stable now (3rd party crates are their own deal). However, I'd expect that many crate authors would want to make their crates compatible with 1.0, if only so that more people can use them soon! You may want to let the bincode project know it doesn't compile with the beta. – Shepmaster Apr 30 '15 at 02:04

0 Answers0