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 1313// See the License for the specific language governing permissions and
1414// limitations under the License.
1515
16- use std:: fmt:: Display ;
16+ use std:: { fmt:: Display , str :: FromStr } ;
1717
1818/// Wrapper that serializes objects as json encoded string for `serde`
1919#[ derive( Debug , Clone ) ]
@@ -54,6 +54,14 @@ impl<T: serde::Serialize> serde::Serialize for JsonEncoded<T> {
5454 }
5555}
5656
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+
5765impl < ' de , T : serde:: Deserialize < ' de > > serde:: Deserialize < ' de > for JsonEncoded < T > {
5866 fn deserialize < D : serde:: Deserializer < ' de > > ( deserializer : D ) -> Result < Self , D :: Error > {
5967 T :: deserialize ( deserializer) . map ( Self )
You can’t perform that action at this time.
0 commit comments