Fixed Sorting
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
#[allow(dead_code)]
|
||||
// Post flair with text, background color and foreground color
|
||||
pub struct Flair(pub String, pub String, pub String);
|
||||
|
||||
#[allow(dead_code)]
|
||||
// Post containing content, metadata and media
|
||||
pub struct Post {
|
||||
pub title: String,
|
||||
@ -42,6 +44,7 @@ pub struct Subreddit {
|
||||
pub icon: String,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
// val() function used to parse JSON from Reddit APIs
|
||||
pub async fn val(j: &serde_json::Value, k: &str) -> String {
|
||||
String::from(j["data"][k].as_str().unwrap_or(""))
|
||||
@ -51,4 +54,10 @@ pub async fn val(j: &serde_json::Value, k: &str) -> String {
|
||||
// nested_val() function used to parse JSON from Reddit APIs
|
||||
pub async fn nested_val(j: &serde_json::Value, n: &str, k: &str) -> String {
|
||||
String::from(j["data"][n][k].as_str().unwrap())
|
||||
}
|
||||
|
||||
// Parser for query params, used in sorting (eg. /r/rust/?sort=hot)
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct Params {
|
||||
pub sort: Option<String>,
|
||||
}
|
Reference in New Issue
Block a user