From eded585f79f7d0b75161fc6be04c3bb71b2e8fa0 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 3 Aug 2024 02:20:06 +0000 Subject: [PATCH] rename some command types for consistency Signed-off-by: Jason Volk --- src/admin/handler.rs | 8 ++++---- src/service/admin/mod.rs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/admin/handler.rs b/src/admin/handler.rs index 738d748c..16518839 100644 --- a/src/admin/handler.rs +++ b/src/admin/handler.rs @@ -11,7 +11,7 @@ use ruma::{ OwnedEventId, }; use service::{ - admin::{CommandInput, CommandOutput, CommandResult, HandlerResult}, + admin::{CommandInput, CommandOutput, HandlerFuture, HandlerResult}, Services, }; @@ -21,12 +21,12 @@ use crate::{admin, admin::AdminCommand, Command}; pub(super) fn complete(line: &str) -> String { complete_command(AdminCommand::command(), line) } #[must_use] -pub(super) fn handle(services: Arc, command: CommandInput) -> HandlerResult { +pub(super) fn handle(services: Arc, command: CommandInput) -> HandlerFuture { Box::pin(handle_command(services, command)) } #[tracing::instrument(skip_all, name = "admin")] -async fn handle_command(services: Arc, command: CommandInput) -> CommandResult { +async fn handle_command(services: Arc, command: CommandInput) -> HandlerResult { AssertUnwindSafe(Box::pin(process_command(services, &command))) .catch_unwind() .await @@ -40,7 +40,7 @@ async fn process_command(services: Arc, command: &CommandInput) -> Com .and_then(|content| reply(content, command.reply_id.clone())) } -fn handle_panic(error: &Error, command: CommandInput) -> CommandResult { +fn handle_panic(error: &Error, command: CommandInput) -> HandlerResult { let link = "Please submit a [bug report](https://github.com/girlbossceo/conduwuit/issues/new). 🥺"; let msg = format!("Panic occurred while processing command:\n```\n{error:#?}\n```\n{link}"); let content = RoomMessageEventContent::notice_markdown(msg); diff --git a/src/service/admin/mod.rs b/src/service/admin/mod.rs index 00d6597e..0e8a65f1 100644 --- a/src/service/admin/mod.rs +++ b/src/service/admin/mod.rs @@ -51,9 +51,9 @@ pub struct CommandInput { } pub type Completer = fn(&str) -> String; -pub type Handler = fn(Arc, CommandInput) -> HandlerResult; -pub type HandlerResult = Pin + Send>>; -pub type CommandResult = Result; +pub type Handler = fn(Arc, CommandInput) -> HandlerFuture; +pub type HandlerFuture = Pin + Send>>; +pub type HandlerResult = Result; pub type CommandOutput = Option; const COMMAND_QUEUE_LIMIT: usize = 512; @@ -173,7 +173,7 @@ impl Service { } } - async fn process_command(&self, command: CommandInput) -> CommandResult { + async fn process_command(&self, command: CommandInput) -> HandlerResult { let Some(services) = self .services .services