From 4f0b923c4f2bc9be80bf1e7ca61cc66c354cc7e0 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Wed, 29 Jan 2025 12:06:58 +0100 Subject: admin api: small fixes --- src/api/admin/macros.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/api/admin/macros.rs') diff --git a/src/api/admin/macros.rs b/src/api/admin/macros.rs index d68ba37f..7082577f 100644 --- a/src/api/admin/macros.rs +++ b/src/api/admin/macros.rs @@ -14,7 +14,7 @@ macro_rules! admin_endpoints { )* } - #[derive(Serialize, Deserialize)] + #[derive(Serialize)] #[serde(untagged)] pub enum AdminApiResponse { $( @@ -22,6 +22,13 @@ macro_rules! admin_endpoints { )* } + #[derive(Serialize, Deserialize)] + pub enum TaggedAdminApiResponse { + $( + $endpoint( [<$endpoint Response>] ), + )* + } + impl AdminApiRequest { pub fn name(&self) -> &'static str { match self { @@ -35,6 +42,16 @@ macro_rules! admin_endpoints { } } + impl AdminApiResponse { + fn tagged(self) -> TaggedAdminApiResponse { + match self { + $( + Self::$endpoint(res) => TaggedAdminApiResponse::$endpoint(res), + )* + } + } + } + #[async_trait] impl EndpointHandler for AdminApiRequest { type Response = AdminApiResponse; -- cgit v1.2.3