We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Value::Tag(1, Box::new(Value::...)
I'm trying to serialize a timestamped Message using a CBOR tag 1 containing an f64.
Message
This code, which I am attempting based on reading cbor4ii's source and may not be correct, hangs. I also tried it with a Value::Integer(0).
cbor4ii
Value::Integer(0)
#[derive(Serialize)] struct Message ( cbor4ii::core::Value, // timestamp String, ); let msg = Message( cbor4ii::core::Value::Tag(1, Box::new(cbor4ii::core::Value::Float(0.0f64))), "Hello World!".to_string(), ); let _ = self.cbor_file.write(to_vec(vec!(), &msg).expect("CBOR serialization failed").as_slice());
Removing the Tag() wrapper, like so, works correctly:
Tag()
let msg = Message( /*cbor4ii::core::Value::Tag(1, Box::new(*/cbor4ii::core::Value::Float(0.0f64)/*))*/, "Hello World!".to_string(), ); let _ = self.cbor_file.write(to_vec(vec!(), &msg).expect("CBOR serialization failed").as_slice());
The text was updated successfully, but these errors were encountered:
to_vec returned an error because serializing Tag is not supported. see https://github.com/quininer/cbor4ii/blob/master/src/core.rs#L172
to_vec
this will cause your program to panic because you are using .expect(). The cause of hangs may be caused by your panic hook.
.expect()
Sorry, something went wrong.
I won't implement it yet, because Tag behaves differently depending on the value, and serde's serialization model does not map this well.
If anyone has a better way of doing it I'd be happy to merge it.
No branches or pull requests
I'm trying to serialize a timestamped
Message
using a CBOR tag 1 containing an f64.This code, which I am attempting based on reading
cbor4ii
's source and may not be correct, hangs. I also tried it with aValue::Integer(0)
.Removing the
Tag()
wrapper, like so, works correctly:The text was updated successfully, but these errors were encountered: