Inital commit

This commit is contained in:
Leon Grünewald 2025-01-25 01:09:48 +01:00
commit 8e26b2cb65
6 changed files with 1667 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
.idea
/target

1562
Cargo.lock generated Normal file

File diff suppressed because it is too large Load diff

12
Cargo.toml Normal file
View file

@ -0,0 +1,12 @@
[package]
name = "rustyfox"
version = "0.1.0"
edition = "2021"
[dependencies]
anyhow = "1.0"
reqwest = "0.12"
tokio = { version = "1.43", features = ["full", "rt-multi-thread"]}
serde = { version = "1.0", features = ["default", "derive"]}
serde_json = { version = "1.0", features = ["default", "std", "alloc"]}
chrono = "0.4"

24
src/client.rs Normal file
View file

@ -0,0 +1,24 @@
use reqwest::header::HeaderMap;
pub struct Client {
request_client: reqwest::Client
}
impl Client {
pub fn new() -> anyhow::Result<Self> {
let headers = HeaderMap::from_iter(vec![
(reqwest::header::CONTENT_TYPE, "application/json".into())
].into_iter());
let request_client = reqwest::ClientBuilder::new()
.default_headers(headers)
.build()?;
Ok(Self {
request_client
})
}
pub fn get_submission<S>(submission_id: S) where S: Into<String> -> anyhow::Result<> {
todo!();
}
}

2
src/lib.rs Normal file
View file

@ -0,0 +1,2 @@
pub mod client;
pub mod models;

65
src/models.rs Normal file
View file

@ -0,0 +1,65 @@
use serde::{Deserialize, Serialize};
use chrono::{DateTime, Utc};
#[derive(Clone, Deserialize, Serialize)]
pub struct Author {
pub name: String,
pub status: String,
pub title: String,
pub avatar_url: String,
pub join_date: DateTime<Utc>,
}
#[derive(Clone, Deserialize, Serialize)]
pub struct Stats {
pub views: i32,
pub comments: i32,
pub favorites: i32,
}
#[derive(Clone, Deserialize, Serialize)]
pub struct UserFolder {
pub name: String,
pub url: String,
pub group: String,
}
#[derive(Clone, Deserialize, Serialize)]
pub struct Comment {
pub id: i32,
pub author: Author,
pub date: DateTime<Utc>,
pub text: String,
pub replies: Vec<String>,
pub reply_to: i32,
pub edited: bool,
pub hidden: bool,
}
#[derive(Clone, Deserialize, Serialize)]
pub struct Submission {
pub id: i32,
pub title: String,
pub author: Author,
pub date: DateTime<Utc>,
pub tags: Vec<String>,
pub category: String,
pub species: String,
pub gender: String,
pub rating: String,
#[serde(rename = "type")]
pub submission_type: String,
pub stats: Stats,
pub description: String,
pub footer: String,
pub mentions: Vec<String>,
pub folder: String,
pub user_folders: Vec<UserFolder>,
pub file_url: String,
pub thumbnail_url: String,
pub comments: Vec<Comment>,
pub prev: i32,
pub next: i32,
pub favorite: bool,
pub favorite_toggle_link: String,
}