use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Deserialize, Debug, Clone)]
pub struct PublicIllust {
pub id: u64,
pub title: String,
#[serde(rename = "illust_type")]
pub illust_type: u8,
pub tags: Vec<String>,
pub caption: String,
pub image_urls: ImageUrls,
pub user: PublicUser,
pub create_date: String,
pub stats: Option<Stats>,
pub r18: bool,
pub page_count: u32,
pub bookmark_count: Option<u32>,
pub comment_count: Option<u32>,
pub view_count: Option<u32>,
}
#[derive(Deserialize, Debug, Clone)]
pub struct ImageUrls {
pub square_medium: Option<String>,
pub medium: Option<String>,
pub large: Option<String>,
pub original: Option<String>,
}
#[derive(Deserialize, Debug, Clone)]
pub struct PublicUser {
pub id: u64,
pub name: String,
pub profile_image_urls: ProfileImageUrls,
pub is_followed: Option<bool>,
}
#[derive(Deserialize, Debug, Clone)]
pub struct ProfileImageUrls {
pub px_16x16: Option<String>,
pub px_50x50: Option<String>,
pub px_170x170: Option<String>,
}
#[derive(Deserialize, Debug, Clone)]
pub struct Stats {
pub bookmarks_count: u32,
pub comments_count: u32,
pub views_count: u32,
pub score: u32,
}
#[derive(Deserialize, Debug)]
pub struct PublicSearchResponse {
pub illusts: Vec<PublicIllust>,
pub next_url: Option<String>,
pub search_meta: Option<SearchMeta>,
}
#[derive(Deserialize, Debug)]
pub struct SearchMeta {
pub search_id: String,
pub time: u64,
}
#[derive(Deserialize, Debug)]
pub struct PublicUserDetail {
pub user: PublicUser,
pub illusts: HashMap<String, PublicIllust>,
pub manga: HashMap<String, PublicIllust>,
pub novels: HashMap<String, PublicNovel>,
pub profile: UserProfile,
pub profile_publicity: UserProfilePublicity,
pub workspace: Workspace,
}
#[derive(Deserialize, Debug)]
pub struct PublicNovel {
pub id: u64,
pub title: String,
pub tags: Vec<String>,
pub caption: String,
pub image_urls: ImageUrls,
pub user: PublicUser,
pub create_date: String,
pub text_length: u32,
pub page_count: u32,
pub visible_page_count: u32,
pub is_muted: bool,
}
#[derive(Deserialize, Debug)]
pub struct UserProfile {
pub birth: String,
pub birth_day: String,
pub birth_year: i32,
pub gender: String,
pub region: String,
pub address_id: u32,
pub country_code: String,
pub job: String,
pub job_id: u32,
pub interests: String,
pub comment: Option<String>,
pub webpage: Option<String>,
pub twitter_account: Option<String>,
pub twitter_url: Option<String>,
pub pawoo_url: Option<String>,
pub is_pawoo_user: Option<bool>,
}
#[derive(Deserialize, Debug)]
pub struct UserProfilePublicity {
pub birth_day: String,
pub gender: String,
pub region: String,
pub job: String,
pub interests: String,
pub comment: String,
pub webpage: String,
pub twitter: String,
pub pawoo: String,
}
#[derive(Deserialize, Debug)]
pub struct Workspace {
pub desk: Option<String>,
pub chair: Option<String>,
pub operating_system: Option<String>,
pub tool: Option<String>,
pub comment: Option<String>,
pub music: Option<String>,
pub tea: Option<String>,
pub pc: Option<String>,
pub monitor: Option<String>,
pub software: Option<String>,
pub scanner: Option<String>,
pub tablet: Option<String>,
pub mouse: Option<String>,
pub printer: Option<String>,
pub desktop: Option<String>,
pub music_player: Option<String>,
pub router: Option<String>,
pub other: Option<String>,
pub camera: Option<String>,
}
#[derive(Deserialize, Debug)]
pub struct PublicUserIllusts {
pub illusts: Vec<PublicIllust>,
pub next_url: Option<String>,
}
#[derive(Deserialize, Debug)]
pub struct PublicUserBookmarks {
pub illusts: Vec<PublicIllust>,
pub next_url: Option<String>,
}
#[derive(Debug, Clone)]
pub enum SearchTarget {
PartialMatchForTags,
ExactMatchForTags,
TitleAndCaption,
Keyword,
}
impl std::fmt::Display for SearchTarget {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
SearchTarget::PartialMatchForTags => write!(f, "partial_match_for_tags"),
SearchTarget::ExactMatchForTags => write!(f, "exact_match_for_tags"),
SearchTarget::TitleAndCaption => write!(f, "title_and_caption"),
SearchTarget::Keyword => write!(f, "keyword"),
}
}
}
#[derive(Debug, Clone)]
pub enum Sort {
DateDesc,
DateAsc,
PopularDesc,
}
impl std::fmt::Display for Sort {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Sort::DateDesc => write!(f, "date_desc"),
Sort::DateAsc => write!(f, "date_asc"),
Sort::PopularDesc => write!(f, "popular_desc"),
}
}
}
#[derive(Debug, Clone)]
pub enum ContentType {
Illust,
Manga,
Ugoira,
}
impl std::fmt::Display for ContentType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ContentType::Illust => write!(f, "illust"),
ContentType::Manga => write!(f, "manga"),
ContentType::Ugoira => write!(f, "ugoira"),
}
}
}
#[derive(Debug, Clone)]
pub enum Filter {
ForIOS,
None,
}
impl std::fmt::Display for Filter {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Filter::ForIOS => write!(f, "for_ios"),
Filter::None => write!(f, ""),
}
}
}
#[derive(Debug, Clone)]
pub enum Duration {
WithinLastDay,
WithinLastWeek,
WithinLastMonth,
}
impl std::fmt::Display for Duration {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Duration::WithinLastDay => write!(f, "within_last_day"),
Duration::WithinLastWeek => write!(f, "within_last_week"),
Duration::WithinLastMonth => write!(f, "within_last_month"),
}
}
}
#[derive(Debug, Clone)]
pub enum Restrict {
Public, Private, }
impl std::fmt::Display for Restrict {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Restrict::Public => write!(f, "public"),
Restrict::Private => write!(f, "private"),
}
}
}