From da41cfc00e13c2a57b386ec0c176b91d6cff912c Mon Sep 17 00:00:00 2001 From: Joseph Holtkamp Date: Sun, 12 Mar 2023 12:15:06 -0500 Subject: [PATCH] Refactored response parsing to only include valuable info --- src/main.rs | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index 41ad033..5c19071 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,17 +1,27 @@ -#![allow(unused)] use reqwest::Result; use serde::{Deserialize, Serialize}; -use serde_json::Value; -use std::collections::HashMap; + +#[derive(Debug, Deserialize, Serialize)] +struct Definition { + source: String, + text: String, + note: Option, + #[serde(rename(deserialize = "partOfSpeech"))] + part_of_speech: String, +} + +#[derive(Debug, Deserialize, Serialize)] +struct ExampleUsage { + url: String, + title: String, + text: String, + id: i32, +} #[derive(Debug, Deserialize, Serialize)] struct WordOfTheDay { - #[serde(rename(deserialize = "contentProvider"))] - content_provider: HashMap, - definitions: Vec>, - examples: Vec>, - #[serde(rename(deserialize = "htmlExtra"))] - html_extra: Option, + definitions: Vec, + examples: Vec, note: String, word: String, }