wip: verbose logging with serde_ignored
this is for using the crate `tracing` in the future
This commit is contained in:
parent
c07a164903
commit
912f024163
3 changed files with 33 additions and 9 deletions
|
@ -19,6 +19,7 @@ secrecy = { version = "0.8.0", features = ["serde"] }
|
|||
serde = { version = "1.0.195", features = ["derive"] }
|
||||
serde_json = "1.0.111"
|
||||
serde_repr = { version = "0.1.18", optional = true }
|
||||
serde_ignored = "0.1"
|
||||
url = "2.5.0"
|
||||
base64 = "0.22"
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ impl OpenIdClient {
|
|||
.form(constants::token::refresh_token_form(refresh_token.as_str()).as_slice())
|
||||
);
|
||||
|
||||
parse_json_response_from_apiresult!(res, TokenResponse)
|
||||
Ok(parse_json_response_from_apiresult!(res, TokenResponse))
|
||||
}
|
||||
|
||||
pub async fn token_authorization(
|
||||
|
@ -65,6 +65,6 @@ impl OpenIdClient {
|
|||
let res = self.client.execute(req).await;
|
||||
let res = parse_response_internal!(res);
|
||||
|
||||
parse_json_response_from_apiresult!(res, TokenResponse)
|
||||
Ok(parse_json_response_from_apiresult!(res, TokenResponse))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,23 +180,46 @@ macro_rules! request_json {
|
|||
macro_rules! parse_json_response {
|
||||
($res: expr, $type: ty) => {{
|
||||
let res = $res.text().await.unwrap();
|
||||
let res = serde_json::from_str::<$type>(&res);
|
||||
let jd = &mut serde_json::Deserializer::from_str(res.as_str());
|
||||
let mut unused = std::collections::BTreeSet::new();
|
||||
|
||||
match res {
|
||||
println!("res({}): {}", stringify!($type), res);
|
||||
let res: Result<$type,_> = serde_ignored::deserialize(jd, |path| {
|
||||
unused.insert(path.to_string());
|
||||
});
|
||||
println!("res({}): {:?}", stringify!($type), unused);
|
||||
|
||||
let res: $type = match res {
|
||||
Ok(res) => res,
|
||||
Err(err) => return Err(crate::LibraryError::from(err)),
|
||||
}
|
||||
};
|
||||
|
||||
res
|
||||
}};
|
||||
}
|
||||
|
||||
macro_rules! parse_json_response_from_apiresult {
|
||||
($res: expr, $type: ty) => {{
|
||||
let res = $res.text().await.unwrap();
|
||||
let res = serde_json::from_str::<APIResult<$type>>(&res);
|
||||
let jd = &mut serde_json::Deserializer::from_str(res.as_str());
|
||||
let mut unused = std::collections::BTreeSet::new();
|
||||
|
||||
match res {
|
||||
println!("res({}): {}", stringify!($type), res);
|
||||
let res: Result<APIResult<$type>,_> = serde_ignored::deserialize(jd, |path| {
|
||||
unused.insert(path.to_string());
|
||||
});
|
||||
println!("res({}): {:?}", stringify!($type), unused);
|
||||
|
||||
let res: LibraryResult<$type> = match res {
|
||||
Ok(res) => res.into(),
|
||||
Err(err) => Err(crate::LibraryError::from(err)),
|
||||
}
|
||||
Err(err) => return Err(crate::LibraryError::from(err)),
|
||||
};
|
||||
|
||||
let res = match res {
|
||||
Ok(res) => res,
|
||||
Err(err) => return Err(crate::LibraryError::from(err)),
|
||||
};
|
||||
|
||||
res
|
||||
}};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue