summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2024-03-12 17:30:35 +0200
committerLars Wirzenius <liw@liw.fi>2024-03-12 17:30:35 +0200
commit4c504912e312e80cc5d67ef22f84d6c8912bbe8f (patch)
tree59337697c1f6a51e4dda54b273e50dc7a3b16d6b
parentde44786001b1a55cdd6c4c10fc80e57d3d352aab (diff)
downloadradicle-ci-broker-4c504912e312e80cc5d67ef22f84d6c8912bbe8f.tar.gz
feat: add Request::try_from_str for tests
Specifically, radicle-native-ci tests. Signed-off-by: Lars Wirzenius <liw@liw.fi>
-rw-r--r--src/msg.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/msg.rs b/src/msg.rs
index 5d4ce27..eb7200a 100644
--- a/src/msg.rs
+++ b/src/msg.rs
@@ -324,6 +324,13 @@ impl Request {
serde_json::from_slice(line.as_bytes()).map_err(MessageError::DeserializeRequest)?;
Ok(req)
}
+
+ /// Parse a request from a string. This is meant for tests to use.
+ pub fn try_from_str(s: &str) -> Result<Self, MessageError> {
+ let req: Self =
+ serde_json::from_slice(s.as_bytes()).map_err(MessageError::DeserializeRequest)?;
+ Ok(req)
+ }
}
fn did_to_author(profile: &Profile, did: &Did) -> Result<Author, MessageError> {