From 6e8e9f59a2c7e3faeb9aceabb26601da6264f373 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 16 Aug 2026 22:07:21 +0200 Subject: [PATCH] change version to string --- szurubooru-client/src/client.rs | 16 +++--- szurubooru-client/src/models.rs | 64 ++++++++++++------------ szurubooru-client/src/py/asynchronous.rs | 44 ++++++++-------- szurubooru-client/src/py/synchronous.rs | 44 ++++++++-------- 4 files changed, 85 insertions(+), 83 deletions(-) diff --git a/szurubooru-client/src/client.rs b/szurubooru-client/src/client.rs index e1a83d4..c1dc0af 100644 --- a/szurubooru-client/src/client.rs +++ b/szurubooru-client/src/client.rs @@ -516,7 +516,7 @@ impl<'a> SzurubooruRequest<'a> { } /// Deletes existing tag category. The tag category to be deleted must have no usages. - pub async fn delete_tag_category(&self, name: T, version: u32) -> SzurubooruResult<()> + pub async fn delete_tag_category(&self, name: T, version: String) -> SzurubooruResult<()> where T: AsRef + Display, { @@ -593,7 +593,7 @@ impl<'a> SzurubooruRequest<'a> { } /// Deletes existing tag. The tag to be deleted must have no usages. - pub async fn delete_tag(&self, name: T, version: u32) -> SzurubooruResult<()> + pub async fn delete_tag(&self, name: T, version: String) -> SzurubooruResult<()> where T: AsRef + Display, { @@ -1127,7 +1127,7 @@ impl<'a> SzurubooruRequest<'a> { } /// Deletes existing post. Related posts and tags are kept. - pub async fn delete_post(&self, post_id: u32, version: u32) -> SzurubooruResult<()> { + pub async fn delete_post(&self, post_id: u32, version: String) -> SzurubooruResult<()> { let path = format!("/api/post/{post_id}"); let version_obj = ResourceVersion { version }; self.do_request::(Method::DELETE, &path, None, Some(&version_obj)) @@ -1249,7 +1249,7 @@ impl<'a> SzurubooruRequest<'a> { pub async fn delete_pool_category( &self, category_name: T, - version: u32, + version: String, ) -> SzurubooruResult<()> where T: AsRef + Display, @@ -1330,7 +1330,7 @@ impl<'a> SzurubooruRequest<'a> { /// Deletes existing pool. All posts in the pool will only have their relation to the pool /// removed. - pub async fn delete_pool(&self, pool_id: u32, version: u32) -> SzurubooruResult<()> { + pub async fn delete_pool(&self, pool_id: u32, version: String) -> SzurubooruResult<()> { let path = format!("/api/pool/{pool_id}"); let version_obj = ResourceVersion { version }; self.do_request::(Method::DELETE, &path, None, Some(&version_obj)) @@ -1384,7 +1384,7 @@ impl<'a> SzurubooruRequest<'a> { } /// Deletes existing comment - pub async fn delete_comment(&self, comment_id: u32, version: u32) -> SzurubooruResult<()> { + pub async fn delete_comment(&self, comment_id: u32, version: String) -> SzurubooruResult<()> { let path = format!("/api/comment/{comment_id}"); let version_obj = ResourceVersion { version }; self.do_request::(Method::DELETE, &path, None, Some(&version_obj)) @@ -1590,7 +1590,7 @@ impl<'a> SzurubooruRequest<'a> { } /// Deletes existing user - pub async fn delete_user(&self, name: T, version: u32) -> SzurubooruResult<()> + pub async fn delete_user(&self, name: T, version: String) -> SzurubooruResult<()> where T: AsRef + Display, { @@ -1656,7 +1656,7 @@ impl<'a> SzurubooruRequest<'a> { &self, name: T, token: T, - version: u32, + version: String, ) -> SzurubooruResult<()> where T: AsRef + Display, diff --git a/szurubooru-client/src/models.rs b/szurubooru-client/src/models.rs index b8d12b5..b7d0272 100644 --- a/szurubooru-client/src/models.rs +++ b/szurubooru-client/src/models.rs @@ -5,11 +5,11 @@ //! See [here](https://github.com/rr-/szurubooru/blob/master/doc/API.md#field-selecting) for //! more information. -use std::cmp::Ordering; use crate::errors::SzurubooruClientError; use chrono::{DateTime, Utc}; use derive_builder::Builder; use serde::{Deserialize, Serialize}; +use std::cmp::Ordering; use std::collections::HashMap; use strum_macros::AsRefStr; @@ -124,7 +124,7 @@ impl MicroTagResource { /// ```json /// { /// ..., -/// "version": 2 +/// "version": "2026-08-16T14:45:37.088202Z" /// } /// ``` /// @@ -134,7 +134,7 @@ impl MicroTagResource { /// encouraged to notify the user about the situation. pub struct ResourceVersion { /// The version itself - pub version: u32, + pub version: String, } #[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)] @@ -146,7 +146,7 @@ pub struct ResourceVersion { /// A single tag. Tags are used to let users search for posts. pub struct TagResource { /// resource version. See [versioning](ResourceVersion) - pub version: u32, + pub version: String, /// a list of tag names (aliases). Tagging a post with any name will automatically assign /// the first name from this list. pub names: Option>, @@ -202,7 +202,7 @@ pub struct CreateUpdateTag { #[serde(skip_serializing_if = "Option::is_none")] #[builder(default)] /// resource version. See [versioning](ResourceVersion) - pub version: Option, + pub version: Option, #[serde(skip_serializing_if = "Option::is_none")] #[builder(default)] /// Tag names and aliases, must match `tag_name_regex` from the server's configuration @@ -234,7 +234,7 @@ pub struct CreateUpdateTag { /// types (such as characters, media type etc.), which improves user experience. pub struct TagCategoryResource { /// resource version. See [versioning](ResourceVersion) - pub version: u32, + pub version: String, /// The name of the tag category pub name: Option, /// The display color of the tag category @@ -265,7 +265,7 @@ pub struct CreateUpdateTagCategory { /// Resource version. See [versioning](ResourceVersion) #[serde(skip_serializing_if = "Option::is_none")] #[builder(default)] - pub version: Option, + pub version: Option, /// The name of the category to create #[serde(skip_serializing_if = "Option::is_none")] #[builder(default)] @@ -288,12 +288,12 @@ pub struct CreateUpdateTagCategory { pub struct MergeTags { /// Version of the tag to remove #[serde(rename = "removeVersion")] - pub remove_tag_version: u32, + pub remove_tag_version: String, /// The name of the tag to remove #[serde(rename = "remove")] pub remove_tag: String, /// The version of the tag to merge TO - pub merge_to_version: u32, + pub merge_to_version: String, /// The name of the tag to merge TO #[serde(rename = "mergeTo")] pub merge_to_tag: String, @@ -420,7 +420,7 @@ pub(crate) struct PostId { /// A post resource pub struct PostResource { /// Resource version. See [versioning](ResourceVersion) - pub version: Option, + pub version: Option, /// The post identifier pub id: Option, /// Time the post was created @@ -545,7 +545,7 @@ pub struct CreateUpdatePost { #[serde(skip_serializing_if = "Option::is_none")] /// Resource version. See [versioning](ResourceVersion) #[builder(default)] - pub version: Option, + pub version: Option, /// Tags to use for this post. If specified tags do not exist yet, they will be automatically /// created. Tags created automatically have no implications, no suggestions, one name and /// their category is set to the first tag category found @@ -606,12 +606,12 @@ pub struct TemporaryFileUpload { pub struct MergePost { /// The version of the post to remove #[serde(rename = "removeVersion")] - pub remove_post_version: u32, + pub remove_post_version: String, /// The ID of the post to remove #[serde(rename = "remove")] pub remove_post: u32, /// The version of the post to merge TO - pub merge_to_version: u32, + pub merge_to_version: String, /// The post ID of the post to merge TO #[serde(rename = "mergeTo")] pub merge_to_post: u32, @@ -645,11 +645,13 @@ pub struct NoteResource { impl PartialEq for NoteResource { fn eq(&self, other: &Self) -> bool { - self.text == other.text && - self.polygon.len() == other.polygon.len() && - self.polygon.iter().zip(other.polygon.iter()).all(|(a, b)| { - a.len() == b.len() && - a.iter().zip(b.iter()).all(|(a, b)| a.total_cmp(b) == Ordering::Equal) + self.text == other.text + && self.polygon.len() == other.polygon.len() + && self.polygon.iter().zip(other.polygon.iter()).all(|(a, b)| { + a.len() == b.len() + && a.iter() + .zip(b.iter()) + .all(|(a, b)| a.total_cmp(b) == Ordering::Equal) }) } } @@ -711,11 +713,11 @@ pub struct UserResource { /// Resource version. See [versioning](ResourceVersion) #[cfg(feature = "python")] #[pyo3(get)] - pub version: Option, + pub version: Option, /// Resource version. See [versioning](ResourceVersion) #[cfg(not(feature = "python"))] - pub version: Option, + pub version: Option, /// The user's username #[cfg(feature = "python")] @@ -896,7 +898,7 @@ pub struct CreateUpdateUser { /// Resource version. See [versioning](ResourceVersion) #[serde(skip_serializing_if = "Option::is_none")] #[builder(default)] - pub version: Option, + pub version: Option, /// The username #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] @@ -972,7 +974,7 @@ pub struct UserAuthTokenResource { /// Time when the token expires pub expiration_time: Option>, /// Resource version. See [versioning](ResourceVersion) - pub version: Option, + pub version: Option, /// time the user token was created pub creation_time: Option>, /// time the user token was edited @@ -1009,7 +1011,7 @@ pub struct CreateUpdateUserAuthToken { /// Resource version. See [versioning](ResourceVersion) #[serde(skip_serializing_if = "Option::is_none")] #[builder(default)] - pub version: Option, + pub version: Option, /// Whether the token is still valid for authentication #[serde(skip_serializing_if = "Option::is_none")] #[builder(default)] @@ -1112,7 +1114,7 @@ impl GlobalInfo { /// types (such as series, relations etc.), which improves user experience. pub struct PoolCategoryResource { /// Resource version. See [versioning](ResourceVersion) - pub version: Option, + pub version: Option, /// The category name pub name: Option, /// The category color @@ -1151,7 +1153,7 @@ pub struct CreateUpdatePoolCategory { #[serde(skip_serializing_if = "Option::is_none")] #[builder(default)] /// Category version (used for updating) - pub version: Option, + pub version: Option, /// Category name #[serde(skip_serializing_if = "Option::is_none")] #[builder(default)] @@ -1171,7 +1173,7 @@ pub struct CreateUpdatePoolCategory { /// Type that represents a Pool resource pub struct PoolResource { /// Resource version. See [versioning](ResourceVersion) - pub version: Option, + pub version: Option, /// The pool identifier pub id: Option, /// A list of pool names (aliases) @@ -1229,7 +1231,7 @@ pub struct CreateUpdatePool { /// Resource version. See [versioning](ResourceVersion) #[serde(skip_serializing_if = "Option::is_none")] #[builder(default)] - pub version: Option, + pub version: Option, /// Names and aliases for this pool. When creating a new pool the first name in this list /// is used as the pool name #[builder(default)] @@ -1269,12 +1271,12 @@ pub struct CreateUpdatePool { pub struct MergePool { /// Version of the pool to remove. Must match the current Pool version #[serde(rename = "removeVersion")] - pub remove_pool_version: u32, + pub remove_pool_version: String, /// Pool ID to remove #[serde(rename = "remove")] pub remove_pool: u32, /// Version of the pool to merge TO - pub merge_to_version: u32, + pub merge_to_version: String, /// Pool ID of the pool to merge TO #[serde(rename = "mergeTo")] pub merge_to_pool: u32, @@ -1319,7 +1321,7 @@ impl MicroPoolResource { /// A type representing a Comment on a post pub struct CommentResource { /// Resource version. See [versioning](ResourceVersion) - pub version: Option, + pub version: Option, /// The comment ID pub id: Option, /// The post ID this comment belongs to @@ -1369,7 +1371,7 @@ pub struct CreateUpdateComment { #[serde(skip_serializing_if = "Option::is_none")] /// Resource version. See [versioning](ResourceVersion) /// Omitted when creating a new comment - pub version: Option, + pub version: Option, /// The text of the comment pub text: String, #[builder(default)] diff --git a/szurubooru-client/src/py/asynchronous.rs b/szurubooru-client/src/py/asynchronous.rs index d5be925..ef9cb31 100644 --- a/szurubooru-client/src/py/asynchronous.rs +++ b/szurubooru-client/src/py/asynchronous.rs @@ -100,7 +100,7 @@ impl PythonAsyncClient { pub async fn update_tag_category( &self, name: String, - version: u32, + version: String, new_name: Option, color: Option, order: Option, @@ -147,7 +147,7 @@ impl PythonAsyncClient { /// Deletes a tag category (async version) /// /// :see: :func:`~szurubooru_client.SzurubooruSyncClient.delete_tag_category` for parameters and return type - pub async fn delete_tag_category(&self, name: String, version: u32) -> PyResult<()> { + pub async fn delete_tag_category(&self, name: String, version: String) -> PyResult<()> { self.client .request() .delete_tag_category(name, version) @@ -241,7 +241,7 @@ impl PythonAsyncClient { pub async fn update_tag( &self, name: String, - version: u32, + version: String, names: Option>, category: Option, description: Option, @@ -305,7 +305,7 @@ impl PythonAsyncClient { /// Deletes an existing tag (async version) /// /// :see: :func:`~szurubooru_client.SzurubooruSyncClient.delete_tag` for parameters and return type - pub async fn delete_tag(&self, name: String, version: u32) -> PyResult<()> { + pub async fn delete_tag(&self, name: String, version: String) -> PyResult<()> { self.client .request() .delete_tag(name, version) @@ -321,9 +321,9 @@ impl PythonAsyncClient { pub async fn merge_tags( &self, remove_tag: String, - remove_tag_version: u32, + remove_tag_version: String, merge_to_tag: String, - merge_to_version: u32, + merge_to_version: String, fields: Option>, ) -> PyResult { let mtags = MergeTagsBuilder::default() @@ -458,7 +458,7 @@ impl PythonAsyncClient { pub async fn update_post( &self, post_id: u32, - post_version: u32, + post_version: String, url: Option, token: Option, file_path: Option, @@ -636,7 +636,7 @@ impl PythonAsyncClient { /// Deletes a post by its ID (async version) /// /// :see: :func:`~szurubooru_client.SzurubooruSyncClient.delete_post` for parameters and return type - pub async fn delete_post(&self, post_id: u32, version: u32) -> PyResult<()> { + pub async fn delete_post(&self, post_id: u32, version: String) -> PyResult<()> { self.client .request() .delete_post(post_id, version) @@ -653,9 +653,9 @@ impl PythonAsyncClient { pub async fn merge_post( &self, remove_post: u32, - remove_post_version: u32, + remove_post_version: String, merge_to_post: u32, - merge_to_version: u32, + merge_to_version: String, replace_post_content: bool, fields: Option>, ) -> PyResult { @@ -804,7 +804,7 @@ impl PythonAsyncClient { pub async fn update_pool_category( &self, name: String, - version: u32, + version: String, new_name: Option, color: Option, fields: Option>, @@ -844,7 +844,7 @@ impl PythonAsyncClient { /// Deletes existing pool category (async version) /// /// :see: :func:`~szurubooru_client.SzurubooruSyncClient.delete_pool_category` for parameters and return type - pub async fn delete_pool_category(&self, name: String, version: u32) -> PyResult<()> { + pub async fn delete_pool_category(&self, name: String, version: String) -> PyResult<()> { self.client .request() .delete_pool_category(name, version) @@ -941,7 +941,7 @@ impl PythonAsyncClient { pub async fn update_pool( &self, pool_id: u32, - version: u32, + version: String, new_names: Option>, category: Option, description: Option, @@ -990,7 +990,7 @@ impl PythonAsyncClient { /// Deletes existing pool (async version) /// /// :see: :func:`~szurubooru_client.SzurubooruSyncClient.delete_pool` for parameters and return type - pub async fn delete_pool(&self, pool_id: u32, version: u32) -> PyResult<()> { + pub async fn delete_pool(&self, pool_id: u32, version: String) -> PyResult<()> { self.client .request() .delete_pool(pool_id, version) @@ -1005,9 +1005,9 @@ impl PythonAsyncClient { pub async fn merge_pools( &self, remove_pool: u32, - remove_pool_version: u32, + remove_pool_version: String, merge_to_pool: u32, - merge_to_version: u32, + merge_to_version: String, fields: Option>, ) -> PyResult { let mpool = MergePoolBuilder::default() @@ -1073,7 +1073,7 @@ impl PythonAsyncClient { pub async fn update_comment( &self, comment_id: u32, - version: u32, + version: String, text: String, fields: Option>, ) -> PyResult { @@ -1108,7 +1108,7 @@ impl PythonAsyncClient { /// Deletes an existing comment (async version) /// /// :see: :func:`~szurubooru_client.SzurubooruSyncClient.delete_comment` for parameters and return type - pub async fn delete_comment(&self, comment_id: u32, version: u32) -> PyResult<()> { + pub async fn delete_comment(&self, comment_id: u32, version: String) -> PyResult<()> { self.client .request() .delete_comment(comment_id, version) @@ -1200,7 +1200,7 @@ impl PythonAsyncClient { pub async fn update_user( &self, name: String, - version: u32, + version: String, new_name: Option, password: Option, rank: Option, @@ -1256,7 +1256,7 @@ impl PythonAsyncClient { /// Deletes an existing user (async version) /// /// :see: :func:`~szurubooru_client.SzurubooruSyncClient.delete_user` for parameters and return type - pub async fn delete_user(&self, user_name: String, version: u32) -> PyResult<()> { + pub async fn delete_user(&self, user_name: String, version: String) -> PyResult<()> { self.client .request() .delete_user(user_name, version) @@ -1320,7 +1320,7 @@ impl PythonAsyncClient { &self, user_name: String, token: String, - version: u32, + version: String, enabled: Option, note: Option, expiration_time: Option>, @@ -1352,7 +1352,7 @@ impl PythonAsyncClient { &self, user_name: String, token: String, - version: u32, + version: String, ) -> PyResult<()> { self.client .request() diff --git a/szurubooru-client/src/py/synchronous.rs b/szurubooru-client/src/py/synchronous.rs index feb5b66..a3ce860 100644 --- a/szurubooru-client/src/py/synchronous.rs +++ b/szurubooru-client/src/py/synchronous.rs @@ -103,7 +103,7 @@ impl PythonSyncClient { pub fn update_tag_category( &self, name: String, - version: u32, + version: String, new_name: Option, color: Option, order: Option, @@ -144,7 +144,7 @@ impl PythonSyncClient { /// :param str name: The tag category's name /// :param int version: The existing resource's version /// - pub fn delete_tag_category(&self, name: String, version: u32) -> PyResult<()> { + pub fn delete_tag_category(&self, name: String, version: String) -> PyResult<()> { self.runtime .block_on(self.client.delete_tag_category(name, version)) } @@ -262,7 +262,7 @@ impl PythonSyncClient { pub fn update_tag( &self, name: String, - version: u32, + version: String, names: Option>, category: Option, description: Option, @@ -305,7 +305,7 @@ impl PythonSyncClient { /// /// :param str name: The name of the tag to delete /// :param int version: The existing resource's version - pub fn delete_tag(&self, name: String, version: u32) -> PyResult<()> { + pub fn delete_tag(&self, name: String, version: String) -> PyResult<()> { self.runtime.block_on(self.client.delete_tag(name, version)) } @@ -331,9 +331,9 @@ impl PythonSyncClient { pub fn merge_tags( &self, remove_tag: String, - remove_tag_version: u32, + remove_tag_version: String, merge_to_tag: String, - merge_to_version: u32, + merge_to_version: String, fields: Option>, ) -> PyResult { self.runtime.block_on(self.client.merge_tags( @@ -490,7 +490,7 @@ impl PythonSyncClient { pub fn update_post( &self, post_id: u32, - post_version: u32, + post_version: String, url: Option, token: Option, file_path: Option, @@ -623,7 +623,7 @@ impl PythonSyncClient { /// /// :param int post_id: The ID of the post to delete /// :param int version: The existing resource's version - pub fn delete_post(&self, post_id: u32, version: u32) -> PyResult<()> { + pub fn delete_post(&self, post_id: u32, version: String) -> PyResult<()> { self.runtime .block_on(self.client.delete_post(post_id, version)) } @@ -654,9 +654,9 @@ impl PythonSyncClient { pub fn merge_post( &self, remove_post: u32, - remove_post_version: u32, + remove_post_version: String, merge_to_post: u32, - merge_to_version: u32, + merge_to_version: String, replace_post_content: bool, fields: Option>, ) -> PyResult { @@ -829,7 +829,7 @@ impl PythonSyncClient { pub fn update_pool_category( &self, name: String, - version: u32, + version: String, new_name: Option, color: Option, fields: Option>, @@ -868,7 +868,7 @@ impl PythonSyncClient { /// /// :param str name: The name of the pool category to delete /// :param int version: The existing resource's version - pub fn delete_pool_category(&self, name: String, version: u32) -> PyResult<()> { + pub fn delete_pool_category(&self, name: String, version: String) -> PyResult<()> { self.runtime .block_on(self.client.delete_pool_category(name, version)) } @@ -988,7 +988,7 @@ impl PythonSyncClient { pub fn update_pool( &self, pool_id: u32, - version: u32, + version: String, new_names: Option>, category: Option, description: Option, @@ -1030,7 +1030,7 @@ impl PythonSyncClient { /// /// :param int pool_id: The ID of the pool to delete /// :param int version: The existing resource's version - pub fn delete_pool(&self, pool_id: u32, version: u32) -> PyResult<()> { + pub fn delete_pool(&self, pool_id: u32, version: String) -> PyResult<()> { self.runtime .block_on(self.client.delete_pool(pool_id, version)) } @@ -1056,9 +1056,9 @@ impl PythonSyncClient { pub fn merge_pools( &self, remove_pool: u32, - remove_pool_version: u32, + remove_pool_version: String, merge_to_pool: u32, - merge_to_version: u32, + merge_to_version: String, fields: Option>, ) -> PyResult { self.runtime.block_on(self.client.merge_pools( @@ -1147,7 +1147,7 @@ impl PythonSyncClient { pub fn update_comment( &self, comment_id: u32, - version: u32, + version: String, text: String, fields: Option>, ) -> PyResult { @@ -1185,7 +1185,7 @@ impl PythonSyncClient { /// /// :param int comment_id: The ID of the comment to delete /// :param int version: The existing resource's version - pub fn delete_comment(&self, comment_id: u32, version: u32) -> PyResult<()> { + pub fn delete_comment(&self, comment_id: u32, version: String) -> PyResult<()> { self.runtime .block_on(self.client.delete_comment(comment_id, version)) } @@ -1312,7 +1312,7 @@ impl PythonSyncClient { pub fn update_user( &self, name: String, - version: u32, + version: String, new_name: Option, password: Option, rank: Option, @@ -1358,7 +1358,7 @@ impl PythonSyncClient { /// /// :param str user_name: The username of the user to delete /// :param int version: The existing resource's version - pub fn delete_user(&self, user_name: String, version: u32) -> PyResult<()> { + pub fn delete_user(&self, user_name: String, version: String) -> PyResult<()> { self.runtime .block_on(self.client.delete_user(user_name, version)) } @@ -1438,7 +1438,7 @@ impl PythonSyncClient { &self, user_name: String, token: String, - version: u32, + version: String, enabled: Option, note: Option, expiration_time: Option>, @@ -1468,7 +1468,7 @@ impl PythonSyncClient { &self, user_name: String, token: String, - version: u32, + version: String, ) -> PyResult<()> { self.runtime .block_on(self.client.delete_user_token(user_name, token, version))