From 445a515930cea647fdd751cef6f0e33af4fa377c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Gr=C3=BCnewald?= Date: Fri, 16 Feb 2024 22:45:06 +0100 Subject: [PATCH] Add missing fields to single post and fix README example --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 2 +- src/errors.rs | 1 - src/post.rs | 49 +++++++++++++++++++++++++++++++++++++++++++++---- 5 files changed, 48 insertions(+), 8 deletions(-) delete mode 100644 src/errors.rs diff --git a/Cargo.lock b/Cargo.lock index da5d420..1063c3d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -574,7 +574,7 @@ dependencies = [ [[package]] name = "r621" -version = "0.2.1" +version = "0.2.2" dependencies = [ "anyhow", "base64", diff --git a/Cargo.toml b/Cargo.toml index 5f1186c..2994e98 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "r621" -version = "0.2.1" +version = "0.2.2" edition = "2021" description = "Provides a client to access e621" homepage = "https://git.doggoat.de/dhalucario/r621" diff --git a/README.md b/README.md index 2c9ce52..88574da 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,6 @@ async fn main() -> Result<(), Box> { }; let mut esix_client = Client::new(auth, user_agent); - let posts = esix_client.list_posts(None, query, None).await?; + let posts = esix_client.list_posts(None, Some(String::from("lucario")), None).await?; } ``` \ No newline at end of file diff --git a/src/errors.rs b/src/errors.rs deleted file mode 100644 index 5a26c02..0000000 --- a/src/errors.rs +++ /dev/null @@ -1 +0,0 @@ -enum Error {} diff --git a/src/post.rs b/src/post.rs index 63178e0..011e9d8 100644 --- a/src/post.rs +++ b/src/post.rs @@ -1,6 +1,7 @@ pub type Id = u64; pub type FileSize = u64; pub type ImageDimension = u64; +pub type VoteCount = i32; #[derive(serde::Serialize, serde::Deserialize, Clone, Debug)] pub struct RawPost { @@ -31,19 +32,27 @@ pub struct Post { pub id: Id, pub created_at: String, pub updated_at: String, - pub tags: PostTags, pub file: PostFile, + pub preview: PostPreview, + pub sample: PostSample, + pub score: PostScore, + pub tags: PostTags, + pub locked_tags: Vec, + pub change_seq: Option, + pub flags: PostFlags, pub rating: String, pub fav_count: u16, pub sources: Vec, + pub pools: Vec, + pub relationships: PostRelationships, pub approver_id: Option, pub uploader_id: Id, pub description: String, pub comment_count: u16, - pub has_notes: bool, pub is_favorited: bool, - pub change_seq: Option, - pub relationships: PostRelationships, + + // Not documented? + pub has_notes: bool } #[derive(serde::Serialize, serde::Deserialize, Clone, Debug)] @@ -68,9 +77,41 @@ pub struct PostFile { pub url: String, } +#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)] +pub struct PostPreview { + width: ImageDimension, + height: ImageDimension, + url: String +} + +#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)] +pub struct PostSample { + has: bool, + width: ImageDimension, + height: ImageDimension, + url: String +} + +#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)] +pub struct PostScore { + pub up: VoteCount, + pub down: VoteCount, + pub total: VoteCount, +} + #[derive(serde::Serialize, serde::Deserialize, Clone, Debug)] pub struct PostRelationships { pub parent_id: Option, pub has_children: bool, pub has_active_children: bool, } + +#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)] +pub struct PostFlags { + pub pending: bool, + pub flagged: bool, + pub note_locked: bool, + pub statued_locked: bool, + pub rating_locked: bool, + pub deleted: bool +}