use serde::Deserialize;
use std::collections::HashMap;
#[derive(Debug, Clone, Copy)]
pub enum FollowRestrict {
Public,
Private,
}
impl ToString for FollowRestrict {
fn to_string(&self) -> String {
match self {
FollowRestrict::Public => "public".to_string(),
FollowRestrict::Private => "private".to_string(),
}
}
}
#[derive(Deserialize, Debug, Clone)]
pub struct CommentAccessControl {
pub allow: bool,
}
#[derive(Deserialize, Debug, Clone)]
pub struct RestrictionAttributes {
#[serde(rename = "type")]
pub restriction_type: String,
pub value: String,
}
#[derive(Deserialize, Debug, Clone)]
pub struct Comment {
pub id: u64,
pub comment: String,
pub date: String,
pub user: Option<User>,
pub parent_comment: Option<Box<Comment>>,
}
#[derive(Deserialize, Debug, Clone)]
pub struct CommentsResponse {
pub comments: Vec<Comment>,
pub next_url: Option<String>,
pub total_comments: Option<u32>,
}
#[derive(Deserialize, Debug, Clone)]
pub struct IllustFollowResponse {
pub illusts: Vec<Illust>,
pub next_url: Option<String>,
}
#[derive(Deserialize, Debug, Clone)]
pub struct IllustBookmarkResponse {
pub success: bool,
pub error: Option<String>,
}
#[derive(Deserialize, Debug, Clone)]
pub struct TrendingTagsResponse {
pub trend_tags: Vec<TrendingTag>,
pub next_url: Option<String>,
}
#[derive(Deserialize, Debug, Clone)]
pub struct TrendingTag {
pub tag: String,
pub translated_name: Option<String>,
pub illust: Option<Vec<Illust>>,
}
#[derive(Deserialize, Debug, Clone)]
pub struct UgoiraMetadataResponse {
pub ugoira_metadata: UgoiraMetadata,
}
#[derive(Deserialize, Debug, Clone)]
pub struct UgoiraMetadata {
pub illust_id: u64,
pub frames: Vec<UgoiraFrame>,
pub mime_type: String,
pub original_src: String,
pub zip_urls: ZipUrls,
}
#[derive(Deserialize, Debug, Clone)]
pub struct UgoiraFrame {
pub file: String,
pub delay: u32,
}
#[derive(Deserialize, Debug, Clone)]
pub struct ZipUrls {
pub medium: String,
pub large: String,
pub original: String,
}
#[derive(Deserialize, Debug, Clone)]
pub struct UserFollowingResponse {
pub user_previews: Vec<UserPreview>,
pub next_url: Option<String>,
}
#[derive(Deserialize, Debug, Clone)]
pub struct UserFollowerResponse {
pub user_previews: Vec<UserPreview>,
pub next_url: Option<String>,
}
#[derive(Deserialize, Debug, Clone)]
pub struct UserMypixivResponse {
pub user_previews: Vec<UserPreview>,
pub next_url: Option<String>,
}
#[derive(Deserialize, Debug, Clone)]
pub struct UserPreview {
pub user: User,
pub illusts: Vec<Illust>,
pub novels: Option<Vec<Novel>>,
pub is_muted: Option<bool>,
}
#[derive(Deserialize, Debug, Clone)]
pub struct Novel {
pub id: u64,
pub title: String,
#[serde(rename = "type")]
pub novel_type: String,
pub caption: String,
pub restrict: u32,
pub user: User,
pub tags: Vec<Tag>,
pub create_date: String,
pub page_count: u32,
pub text_length: u32,
pub series: Option<Series>,
pub total_view: u64,
pub total_bookmarks: u64,
pub is_bookmarked: bool,
pub visible: bool,
pub is_muted: bool,
pub is_mypixiv_only: bool,
pub is_x_restricted: bool,
pub novel_ai_type: u32,
pub comment_access_control: Option<CommentAccessControl>,
}
#[derive(Deserialize, Debug, Clone)]
pub struct ImageUrls {
pub square_medium: String,
pub medium: String,
pub large: String,
}
#[derive(Deserialize, Debug, Clone)]
pub struct ProfileImageUrls {
pub medium: String,
}
#[derive(Deserialize, Debug, Clone)]
pub struct User {
pub id: u64,
pub name: String,
pub account: String,
pub profile_image_urls: ProfileImageUrls,
pub comment: Option<String>,
pub is_followed: Option<bool>,
}
#[derive(Deserialize, Debug, Clone)]
pub struct Tag {
pub name: String,
pub translated_name: Option<String>,
}
#[derive(Deserialize, Debug, Clone)]
pub struct MetaSinglePage {
pub original_image_url: Option<String>,
}
#[derive(Deserialize, Debug, Clone)]
pub struct MetaPage {
pub image_urls: ImageUrls,
}
#[derive(Deserialize, Debug, Clone)]
pub struct Series {
pub id: u64,
pub title: String,
}
#[derive(Deserialize, Debug, Clone)]
pub struct Illust {
pub id: u64,
pub title: String,
#[serde(rename = "type")]
pub illust_type: String,
pub image_urls: ImageUrls,
pub caption: String,
pub restrict: u32,
pub user: User,
pub tags: Vec<Tag>,
pub tools: Vec<String>,
pub create_date: String,
pub page_count: u32,
pub width: u32,
pub height: u32,
pub sanity_level: u32,
pub x_restrict: u32,
pub series: Option<Series>,
pub meta_single_page: MetaSinglePage,
pub meta_pages: Vec<MetaPage>,
#[serde(rename = "total_view_count")]
pub total_view: u64,
#[serde(rename = "total_bookmarks_count")]
pub total_bookmarks: u64,
pub is_bookmarked: bool,
pub visible: bool,
pub is_muted: bool,
pub illust_ai_type: u32,
pub illust_book_style: u32,
pub total_comments: Option<u32>,
#[serde(default)]
pub comment_access_control: Option<CommentAccessControl>,
#[serde(default)]
pub restriction_attributes: Option<Vec<RestrictionAttributes>>,
}
#[derive(Deserialize, Debug, Clone)]
pub struct IllustDetail {
pub illust: Illust,
}
#[derive(Deserialize, Debug, Clone)]
pub struct RankingResponse {
pub illusts: Vec<Illust>,
pub next_url: Option<String>,
pub date: Option<String>,
pub mode: Option<String>,
}
#[derive(Deserialize, Debug, Clone)]
pub struct RecommendedResponse {
pub illusts: Vec<Illust>,
pub next_url: Option<String>,
pub ranking_label: Option<RankingLabel>,
}
#[derive(Deserialize, Debug, Clone)]
pub struct RankingLabel {
pub text: String,
#[serde(rename = "type")]
pub label_type: String,
}
#[derive(Deserialize, Debug, Clone)]
pub struct SearchIllustResponse {
pub illusts: Vec<Illust>,
pub next_url: Option<String>,
pub search_span_limit: u32,
pub show_ai: bool,
}
#[derive(Debug, Clone, Copy)]
pub enum SearchTarget {
PartialMatchForTags,
ExactMatchForTags,
TitleAndCaption,
Keyword,
}
impl ToString for SearchTarget {
fn to_string(&self) -> String {
match self {
SearchTarget::PartialMatchForTags => "partial_match_for_tags".to_string(),
SearchTarget::ExactMatchForTags => "exact_match_for_tags".to_string(),
SearchTarget::TitleAndCaption => "title_and_caption".to_string(),
SearchTarget::Keyword => "keyword".to_string(),
}
}
}
#[derive(Debug, Clone, Copy)]
pub enum Sort {
DateDesc,
DateAsc,
PopularDesc,
}
impl ToString for Sort {
fn to_string(&self) -> String {
match self {
Sort::DateDesc => "date_desc".to_string(),
Sort::DateAsc => "date_asc".to_string(),
Sort::PopularDesc => "popular_desc".to_string(),
}
}
}
#[derive(Debug, Clone, Copy)]
pub enum RankingMode {
Day,
Week,
Month,
DayMale,
DayFemale,
WeekOriginal,
WeekRookie,
DayManga,
DayR18,
DayMaleR18,
DayFemaleR18,
WeekR18,
WeekR18g,
}
impl ToString for RankingMode {
fn to_string(&self) -> String {
match self {
RankingMode::Day => "day".to_string(),
RankingMode::Week => "week".to_string(),
RankingMode::Month => "month".to_string(),
RankingMode::DayMale => "day_male".to_string(),
RankingMode::DayFemale => "day_female".to_string(),
RankingMode::WeekOriginal => "week_original".to_string(),
RankingMode::WeekRookie => "week_rookie".to_string(),
RankingMode::DayManga => "day_manga".to_string(),
RankingMode::DayR18 => "day_r18".to_string(),
RankingMode::DayMaleR18 => "day_male_r18".to_string(),
RankingMode::DayFemaleR18 => "day_female_r18".to_string(),
RankingMode::WeekR18 => "week_r18".to_string(),
RankingMode::WeekR18g => "week_r18g".to_string(),
}
}
}
#[derive(Debug, Clone, Copy)]
pub enum ContentType {
Illust,
Manga,
}
impl ToString for ContentType {
fn to_string(&self) -> String {
match self {
ContentType::Illust => "illust".to_string(),
ContentType::Manga => "manga".to_string(),
}
}
}
#[derive(Debug, Clone, Copy)]
pub enum Filter {
ForIOS,
None,
}
impl ToString for Filter {
fn to_string(&self) -> String {
match self {
Filter::ForIOS => "for_ios".to_string(),
Filter::None => "".to_string(),
}
}
}
#[derive(Debug, Clone, Copy)]
pub enum Duration {
WithinLastDay,
WithinLastWeek,
WithinLastMonth,
}
impl ToString for Duration {
fn to_string(&self) -> String {
match self {
Duration::WithinLastDay => "within_last_day".to_string(),
Duration::WithinLastWeek => "within_last_week".to_string(),
Duration::WithinLastMonth => "within_last_month".to_string(),
}
}
}