From df80c1621d9fe57de340da501dd8158ab768149c Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Thu, 18 May 2023 10:37:22 +0200 Subject: [PATCH] Move JSON creation out of Signer trait --- src/lib.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 0033628..c242ffc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -359,11 +359,12 @@ impl Client { }; let nonce = nonce.ok_or("no nonce found")?; + let body = signer.key().signed_json(payload, signer.header(&nonce, url))?; let request = Request::builder() .method(Method::POST) .uri(url) .header(CONTENT_TYPE, JOSE_JSON) - .body(signer.signed_json(payload, &nonce, url)?) + .body(body) .unwrap(); Ok(self.client.request(request).await?) @@ -444,15 +445,6 @@ impl Signer for Key { } trait Signer { - fn signed_json( - &self, - payload: Option<&impl Serialize>, - nonce: &str, - url: &str, - ) -> Result { - self.key().signed_json(payload, self.header(nonce, url)) - } - fn header<'n, 'u: 'n, 's: 'u>(&'s self, nonce: &'n str, url: &'u str) -> Header<'n>; fn key(&self) -> &Key;