Open Boscop opened 7 years ago
Presently there is no way to easily serialize or deserialize. There are some macros to assist, but mostly, you just have to manually create or read from wamp::Value. For example, to create a JSON Object, you'd create a HashMap from String to Value, insert the values you want, then wrap it in a Value::Dict. Something like this:
let mut send_obj = HashMap::new();
send_obj.insert("key1".to_string(), Value::Integer(5));
send_obj.insert("key2".to_string(), Value::String("Value".to_string()))
let final_value = Value::Dict(send_obj);
In future, I'd like to make this easier, using Into
, but I haven't done so yet.
At present, there is no way to deal with floats, but that could be added fairly easily. I will say that aside from this, both JSON and MsgPack are supported, with MsgPack being favoured if available.
I want to send complex structs over wamp, is there a way to auto (de)serialize them to/from wamp::Value? http://wamp-proto.org/static/rfc/draft-oberstet-hybi-crossbar-wamp.html#serializations
So it should be possible.
Btw, how can I encode floats to send over wamp? (Using autobahn.js on the client)