-
Notifications
You must be signed in to change notification settings - Fork 64
Closed
Description
I'm trying to create my data object and serialize it for sending through my network. but I'm not able to borrow "src" in my object.
I need the src to use it in the send_to() method.
is that a bug or the structure should be this way only?
let mut data = object!{
"HEADER" => "RES:REGISTER",
"SOURCE" => &src,
"BODY" => object!{
"UUID" => reg_serial
}
};
// even i've tried this
//data["SOURCE"] = &src.into();
let serialised_data = json::stringify(data);
socket.send_to(&serialised_data.into_bytes(), &src).expect("cannot send");
the error is
error[E0277]: the trait bound `json::value::JsonValue: std::convert::From<&std::string::String>` is not satisfied
--> src/main.rs:95:20
|
95 | let mut data = object!{
| ____________________^
96 | | "HEADER" => "RES:REGISTER",
97 | | "SOURCE" => &src,
98 | | "BODY" => object!{
99 | | "UUID" => reg_serial
100 | | }
101 | | };
| |_____^ the trait `std::convert::From<&std::string::String>` is not implemented for `json::value::JsonValue`
|
= help: the following implementations were found:
<json::value::JsonValue as std::convert::From<bool>>
<json::value::JsonValue as std::convert::From<i8>>
<json::value::JsonValue as std::convert::From<isize>>
<json::value::JsonValue as std::convert::From<usize>>
and 17 others
= note: required because of the requirements on the impl of `std::convert::Into<json::value::JsonValue>` for `&std::string::String`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to previous error
Metadata
Metadata
Assignees
Labels
No labels