From 2cea08a292a75abce7130c1d8522de7cb9739cb6 Mon Sep 17 00:00:00 2001 From: jakka Date: Wed, 17 Sep 2025 23:02:14 +0300 Subject: implemeted better nested hydrus api response objects --- src/types.rs | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'src/types.rs') diff --git a/src/types.rs b/src/types.rs index b6e9db4..8ea8350 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,6 +1,5 @@ use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; -use std::collections::HashMap; use thiserror::Error; #[derive(Error, Debug)] @@ -33,6 +32,14 @@ impl From for HydrusError { } } +#[derive(Deserialize, Debug)] +pub struct HydrusResponse { + #[serde(alias = "service", alias = "services")] + pub body: T, + pub version: u64, + pub hydrus_version: u64, +} + #[derive(PartialEq, Debug, Clone, Serialize_repr, Deserialize_repr)] #[repr(u8)] pub enum HydrusPermissions { @@ -111,22 +118,6 @@ pub struct Service { pub max_stars: Option, } -#[derive(Deserialize, Debug)] -pub struct ServiceResponse { - services: HashMap, -} - -impl ServiceResponse { - pub fn service_vec(mut self) -> Vec { - let mut res = Vec::new(); - for (key, mut service) in self.services.drain() { - service.service_key = key; - res.push(service); - } - res - } -} - pub enum FileDomain { FileServiceKey(String), FileServiceKeys(Vec), -- cgit v1.3.1