diff options
author | Lars Wirzenius <liw@liw.fi> | 2024-03-12 17:30:35 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2024-03-12 17:30:35 +0200 |
commit | 4c504912e312e80cc5d67ef22f84d6c8912bbe8f (patch) | |
tree | 59337697c1f6a51e4dda54b273e50dc7a3b16d6b | |
parent | de44786001b1a55cdd6c4c10fc80e57d3d352aab (diff) | |
download | radicle-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.rs | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -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> { |