dgraph_tonic/api/
response.rs1use serde::de::{self};
2use serde_json::error::Error;
3use serde_json::Value;
4
5use crate::Response;
6
7impl Response {
8 pub fn try_into<'a, T>(&'a self) -> Result<T, Error>
12 where
13 T: de::Deserialize<'a>,
14 {
15 let result: T = serde_json::from_slice(&self.json)?;
16 Ok(result)
17 }
18
19 pub fn try_into_owned<T>(self) -> Result<T, Error>
23 where
24 T: de::DeserializeOwned,
25 {
26 let result: T = serde_json::from_slice(&self.json)?;
27 Ok(result)
28 }
29}
30
31impl From<Response> for Value {
32 fn from(reps: Response) -> Self {
33 serde_json::from_slice(&reps.json).expect("JSON")
34 }
35}