From 3f00e084224199ca1f14a28ab7649c2efd8930f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Fri, 27 Jun 2025 08:29:57 +0000 Subject: [PATCH] consolidate `sharry::api` module --- src/sharry/api/{id.rs => ids.rs} | 0 src/sharry/api/json.rs | 41 --------------------------- src/sharry/api/mod.rs | 48 +++++++++++++++++++++++++++++--- 3 files changed, 44 insertions(+), 45 deletions(-) rename src/sharry/api/{id.rs => ids.rs} (100%) delete mode 100644 src/sharry/api/json.rs diff --git a/src/sharry/api/id.rs b/src/sharry/api/ids.rs similarity index 100% rename from src/sharry/api/id.rs rename to src/sharry/api/ids.rs diff --git a/src/sharry/api/json.rs b/src/sharry/api/json.rs deleted file mode 100644 index 2f6f680..0000000 --- a/src/sharry/api/json.rs +++ /dev/null @@ -1,41 +0,0 @@ -use serde::{Deserialize, Serialize}; - -#[derive(Serialize, Debug)] -#[allow(non_snake_case)] -pub struct NewShareRequest { - name: String, - validity: u32, - description: Option, - maxViews: u32, - password: Option, -} - -impl NewShareRequest { - pub fn new( - name: impl Into, - description: Option>, - max_views: u32, - ) -> Self { - Self { - name: name.into(), - validity: 0, - description: description.map(Into::into), - maxViews: max_views, - password: None, - } - } -} - -#[derive(Deserialize, Debug)] -pub struct NewShareResponse { - pub success: bool, - pub message: String, - pub id: String, -} - -#[derive(Deserialize, Debug)] -#[allow(dead_code)] -pub struct NotifyShareResponse { - pub success: bool, - pub message: String, -} diff --git a/src/sharry/api/mod.rs b/src/sharry/api/mod.rs index b272b6b..5c084ea 100644 --- a/src/sharry/api/mod.rs +++ b/src/sharry/api/mod.rs @@ -1,7 +1,47 @@ -mod id; -mod json; +mod ids; mod uri; -pub use id::{AliasID, FileID, ShareID}; -pub use json::{NewShareRequest, NewShareResponse, NotifyShareResponse}; +use serde::{Deserialize, Serialize}; + +pub use ids::{AliasID, FileID, ShareID}; pub use uri::Uri; + +#[derive(Serialize, Debug)] +#[allow(non_snake_case)] +pub struct NewShareRequest { + name: String, + validity: u32, + description: Option, + maxViews: u32, + password: Option, +} + +impl NewShareRequest { + pub fn new( + name: impl Into, + description: Option>, + max_views: u32, + ) -> Self { + Self { + name: name.into(), + validity: 0, + description: description.map(Into::into), + maxViews: max_views, + password: None, + } + } +} + +#[derive(Deserialize, Debug)] +pub struct NewShareResponse { + pub success: bool, + pub message: String, + pub id: String, +} + +#[derive(Deserialize, Debug)] +#[allow(dead_code)] +pub struct NotifyShareResponse { + pub success: bool, + pub message: String, +}