File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 13
13
// See the License for the specific language governing permissions and
14
14
// limitations under the License.
15
15
16
- use std:: fmt:: Display ;
16
+ use std:: { fmt:: Display , str :: FromStr } ;
17
17
18
18
/// Wrapper that serializes objects as json encoded string for `serde`
19
19
#[ derive( Debug , Clone ) ]
@@ -54,6 +54,14 @@ impl<T: serde::Serialize> serde::Serialize for JsonEncoded<T> {
54
54
}
55
55
}
56
56
57
+ impl < T : for < ' de > serde:: Deserialize < ' de > > FromStr for JsonEncoded < T > {
58
+ type Err = serde_json:: Error ;
59
+
60
+ fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
61
+ serde_json:: from_str ( s) . map ( Self )
62
+ }
63
+ }
64
+
57
65
impl < ' de , T : serde:: Deserialize < ' de > > serde:: Deserialize < ' de > for JsonEncoded < T > {
58
66
fn deserialize < D : serde:: Deserializer < ' de > > ( deserializer : D ) -> Result < Self , D :: Error > {
59
67
T :: deserialize ( deserializer) . map ( Self )
You can’t perform that action at this time.
0 commit comments