Ralith / hecs

A handy ECS
Apache License 2.0
967 stars 82 forks source link

(De)Serialization example #371

Closed GeTechG closed 4 months ago

GeTechG commented 4 months ago

Could you please make an example of (de)serialization. Actually, I figured out how, but I'm having trouble with RON. I'm getting this error. let value = serialize::row::serialize(&world, &mut Context, ron::ser::Serializer);

error[E0423]: expected value, found struct `ron::ser::Serializer`
   --> src/main.rs:60:77
    |
60  |                 let value = serialize::row::serialize(&world, &mut Context, ron::ser::Serializer);
    |                                                                             ^^^^^^^^^^^^^^^^^^^^
    |
   ::: /home/sergey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ron-0.8.1/src/ser/mod.rs:238:1
    |
238 | pub struct Serializer<W: io::Write> {
    | ----------------------------------- `ron::ser::Serializer` defined here

P.s found a solution

let mut vec = Vec::new();
let mut serializer = Serializer::with_options(&mut vec, None, Default::default()).unwrap();
let value = serialize::row::serialize(&world, &mut Context, &mut serializer).unwrap();
Ralith commented 4 months ago

There doesn't seem to be an outstanding question here.