simplify read_stream
This commit is contained in:
parent
ca9b987555
commit
9a2304c8b0
1 changed files with 2 additions and 6 deletions
|
@ -121,10 +121,7 @@ impl RedisService {
|
||||||
if let Some(BulkString(data)) = stream {
|
if let Some(BulkString(data)) = stream {
|
||||||
let string_data = std::str::from_utf8(data);
|
let string_data = std::str::from_utf8(data);
|
||||||
return match string_data {
|
return match string_data {
|
||||||
Ok(string_data) => {
|
Ok(string_data) => Ok(serde_json::from_str(string_data)?),
|
||||||
let deserialized_data: T = serde_json::from_str(string_data)?;
|
|
||||||
Ok(deserialized_data)
|
|
||||||
}
|
|
||||||
Err(err) => Err(anyhow!("can't convert data to string: {err}")),
|
Err(err) => Err(anyhow!("can't convert data to string: {err}")),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -252,9 +249,8 @@ mod tests {
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
assert_eq!(result, post);
|
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
assert_eq!(result, post);
|
||||||
cleanup(&mut service).await;
|
cleanup(&mut service).await;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue