rename some command types for consistency
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
a552321287
commit
eded585f79
2 changed files with 8 additions and 8 deletions
|
@ -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<Services>, command: CommandInput) -> HandlerResult {
|
||||
pub(super) fn handle(services: Arc<Services>, command: CommandInput) -> HandlerFuture {
|
||||
Box::pin(handle_command(services, command))
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip_all, name = "admin")]
|
||||
async fn handle_command(services: Arc<Services>, command: CommandInput) -> CommandResult {
|
||||
async fn handle_command(services: Arc<Services>, command: CommandInput) -> HandlerResult {
|
||||
AssertUnwindSafe(Box::pin(process_command(services, &command)))
|
||||
.catch_unwind()
|
||||
.await
|
||||
|
@ -40,7 +40,7 @@ async fn process_command(services: Arc<Services>, 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);
|
||||
|
|
|
@ -51,9 +51,9 @@ pub struct CommandInput {
|
|||
}
|
||||
|
||||
pub type Completer = fn(&str) -> String;
|
||||
pub type Handler = fn(Arc<crate::Services>, CommandInput) -> HandlerResult;
|
||||
pub type HandlerResult = Pin<Box<dyn Future<Output = CommandResult> + Send>>;
|
||||
pub type CommandResult = Result<CommandOutput, Error>;
|
||||
pub type Handler = fn(Arc<crate::Services>, CommandInput) -> HandlerFuture;
|
||||
pub type HandlerFuture = Pin<Box<dyn Future<Output = HandlerResult> + Send>>;
|
||||
pub type HandlerResult = Result<CommandOutput>;
|
||||
pub type CommandOutput = Option<RoomMessageEventContent>;
|
||||
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue