Radish alpha
r
Radicle CI broker
Radicle
Git (anonymous pull)
Log in to clone via SSH
feat(src/msg.rs): add a Response constructor from string slice
Lars Wirzenius committed 2 years ago
commit fbd1911e2fa6d97e8efa66afb14b162c00d59700
parent 1321c25f296ccf6ef80c7eeb1136d9bbd786af86
1 file changed +9 -0
modified src/msg.rs
@@ -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.