Add missing fields to single post and fix README example

This commit is contained in:
Leon Grünewald 2024-02-16 22:45:06 +01:00
parent bbe42ba1ee
commit 119430966b
5 changed files with 48 additions and 8 deletions

2
Cargo.lock generated
View file

@ -574,7 +574,7 @@ dependencies = [
[[package]] [[package]]
name = "r621" name = "r621"
version = "0.2.1" version = "0.2.2"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"base64", "base64",

View file

@ -1,6 +1,6 @@
[package] [package]
name = "r621" name = "r621"
version = "0.2.1" version = "0.2.2"
edition = "2021" edition = "2021"
description = "Provides a client to access e621" description = "Provides a client to access e621"
homepage = "https://git.doggoat.de/dhalucario/r621" homepage = "https://git.doggoat.de/dhalucario/r621"

View file

@ -55,6 +55,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}; };
let mut esix_client = Client::new(auth, user_agent); 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?;
} }
``` ```

View file

@ -1 +0,0 @@
enum Error {}

View file

@ -1,6 +1,7 @@
pub type Id = u64; pub type Id = u64;
pub type FileSize = u64; pub type FileSize = u64;
pub type ImageDimension = u64; pub type ImageDimension = u64;
pub type VoteCount = i32;
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)] #[derive(serde::Serialize, serde::Deserialize, Clone, Debug)]
pub struct RawPost { pub struct RawPost {
@ -31,19 +32,27 @@ pub struct Post {
pub id: Id, pub id: Id,
pub created_at: String, pub created_at: String,
pub updated_at: String, pub updated_at: String,
pub tags: PostTags,
pub file: PostFile, pub file: PostFile,
pub preview: PostPreview,
pub sample: PostSample,
pub score: PostScore,
pub tags: PostTags,
pub locked_tags: Vec<String>,
pub change_seq: Option<u128>,
pub flags: PostFlags,
pub rating: String, pub rating: String,
pub fav_count: u16, pub fav_count: u16,
pub sources: Vec<String>, pub sources: Vec<String>,
pub pools: Vec<Id>,
pub relationships: PostRelationships,
pub approver_id: Option<Id>, pub approver_id: Option<Id>,
pub uploader_id: Id, pub uploader_id: Id,
pub description: String, pub description: String,
pub comment_count: u16, pub comment_count: u16,
pub has_notes: bool,
pub is_favorited: bool, pub is_favorited: bool,
pub change_seq: Option<u128>,
pub relationships: PostRelationships, // Not documented?
pub has_notes: bool
} }
#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)] #[derive(serde::Serialize, serde::Deserialize, Clone, Debug)]
@ -68,9 +77,41 @@ pub struct PostFile {
pub url: String, 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)] #[derive(serde::Serialize, serde::Deserialize, Clone, Debug)]
pub struct PostRelationships { pub struct PostRelationships {
pub parent_id: Option<Id>, pub parent_id: Option<Id>,
pub has_children: bool, pub has_children: bool,
pub has_active_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
}