use anyhow::Result;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
pub struct Record {
pub fileid: String,
pub title: String,
pub category: String,
#[serde(rename = "type")]
pub kind: String,
pub os: String,
pub rating: String,
pub downloads: String,
pub published: String,
pub sortdate: String,
pub versionid: String,
pub filename: String,
pub size: String,
pub location: String,
pub author: String,
}
impl Record {
fn _print(&self) {
println!("{} {}", self.kind, self.title);
}
pub fn columns(&self) -> Vec<&str> {
vec![&self.title, &self.kind, &self.author]
}
}
pub fn get_file_list() -> Result<Vec<Record>> {
let url = "https://files.mega65.org/php/readfilespublic.php";
let body = reqwest::blocking::get(url)?.text()?;
Ok(serde_json::from_str(&body)?)
}