aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src
diff options
context:
space:
mode:
authorGeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>2023-01-04 11:50:52 +0100
committerGitHub <noreply@github.com>2023-01-04 11:50:52 +0100
commit8d9dc830476170d01f94fe4dc6967b3d4ecdbab0 (patch)
tree23cd7f3ccb4638b82e134ea2c13a1267539130b1 /src-tauri/src
parent0de71a39f360a056c161b6b352f25642da57728a (diff)
downloadFlightCore-8d9dc830476170d01f94fe4dc6967b3d4ecdbab0.tar.gz
FlightCore-8d9dc830476170d01f94fe4dc6967b3d4ecdbab0.zip
refactor: Deserialize into struct directly (#127)
Instead of deserializing into a generic serde struct and then extracting specific value from it, deserialize directly into the struct we want.
Diffstat (limited to 'src-tauri/src')
-rw-r--r--src-tauri/src/github/release_notes.rs23
1 files changed, 2 insertions, 21 deletions
diff --git a/src-tauri/src/github/release_notes.rs b/src-tauri/src/github/release_notes.rs
index f139ead5..803132e2 100644
--- a/src-tauri/src/github/release_notes.rs
+++ b/src-tauri/src/github/release_notes.rs
@@ -91,28 +91,9 @@ pub async fn get_northstar_release_notes() -> Result<Vec<ReleaseInfo>, String> {
let url = "https://api.github.com/repos/R2Northstar/Northstar/releases";
let res = fetch_github_releases_api(url).await?;
- let json_response: Vec<serde_json::Value> =
+ let release_info_vector: Vec<ReleaseInfo> =
serde_json::from_str(&res).expect("JSON was not well-formatted");
println!("Done checking GitHub API");
- return Ok(json_response
- .iter()
- .map(|release| ReleaseInfo {
- name: release
- .get("name")
- .and_then(|value| value.as_str())
- .unwrap()
- .to_string(),
- published_at: release
- .get("published_at")
- .and_then(|value| value.as_str())
- .unwrap()
- .to_string(),
- body: release
- .get("body")
- .and_then(|value| value.as_str())
- .unwrap()
- .to_string(),
- })
- .collect());
+ return Ok(release_info_vector);
}