diff options
author | Lars Wirzenius <liw@liw.fi> | 2024-02-02 17:31:08 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2024-02-02 17:38:26 +0200 |
commit | fbd1911e2fa6d97e8efa66afb14b162c00d59700 (patch) | |
tree | 8c5f403e2cb798d94a7343c123240d1973a55485 | |
parent | 1321c25f296ccf6ef80c7eeb1136d9bbd786af86 (diff) | |
download | radicle-ci-broker-fbd1911e2fa6d97e8efa66afb14b162c00d59700.tar.gz |
feat(src/msg.rs): add a Response constructor from string slice
This will make it easier to process adapter output line by line.
Signed-off-by: Lars Wirzenius <liw@liw.fi>
-rw-r--r-- | src/msg.rs | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -522,6 +522,15 @@ impl Response { Ok(Some(req)) } } + + /// Read a response from a string slice. This is meant for the + /// broker to use. + #[allow(clippy::should_implement_trait)] + pub fn from_str(line: &str) -> Result<Self, MessageError> { + let req: Self = + serde_json::from_slice(line.as_bytes()).map_err(MessageError::DeserializeResponse)?; + Ok(req) + } } /// All possible errors from the CI broker messages. |