fix(apb): setting href always succeeds

This commit is contained in:
əlemi 2024-05-19 21:18:58 +02:00
parent 65aee2a27e
commit eddde7c8b9
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -65,17 +65,15 @@ impl Link for serde_json::Value {
#[cfg(feature = "unstructured")]
impl LinkMut for serde_json::Value {
// TODO this can fail, but it should never do!
fn set_href(mut self, href: &str) -> Self {
match &mut self {
serde_json::Value::String(x) => *x = href.to_string(),
serde_json::Value::Object(map) => {
map.insert(
"href".to_string(),
serde_json::Value::String(href.to_string())
);
},
_ => tracing::error!("failed setting href on invalid json Link object"),
x => *x = serde_json::Value::String(href.to_string()),
}
self
}