From 4e1c2b9f04073294ecb8402486c20d9c01721598 Mon Sep 17 00:00:00 2001 From: Jokler Date: Wed, 14 Oct 2020 00:19:27 +0200 Subject: Replace channels&locks with actors & log with slog --- src/web_server/bot_executor.rs | 63 ------------------------------------------ 1 file changed, 63 deletions(-) delete mode 100644 src/web_server/bot_executor.rs (limited to 'src/web_server/bot_executor.rs') diff --git a/src/web_server/bot_executor.rs b/src/web_server/bot_executor.rs deleted file mode 100644 index 0d3e7b7..0000000 --- a/src/web_server/bot_executor.rs +++ /dev/null @@ -1,63 +0,0 @@ -use std::sync::Arc; - -use actix::{Actor, Context, Handler, Message}; - -use crate::bot::MasterBot; -use crate::web_server::BotData; - -pub struct BotExecutor(pub Arc); - -impl Actor for BotExecutor { - type Context = Context; -} - -pub struct BotNameListRequest; - -impl Message for BotNameListRequest { - // A plain Vec does not work for some reason - type Result = Result, ()>; -} - -impl Handler for BotExecutor { - type Result = Result, ()>; - - fn handle(&mut self, _: BotNameListRequest, _: &mut Self::Context) -> Self::Result { - let bot = &self.0; - - Ok(bot.bot_names()) - } -} - -pub struct BotDataListRequest; - -impl Message for BotDataListRequest { - // A plain Vec does not work for some reason - type Result = Result, ()>; -} - -impl Handler for BotExecutor { - type Result = Result, ()>; - - fn handle(&mut self, _: BotDataListRequest, _: &mut Self::Context) -> Self::Result { - let bot = &self.0; - - Ok(bot.bot_datas()) - } -} - -pub struct BotDataRequest(pub String); - -impl Message for BotDataRequest { - type Result = Option; -} - -impl Handler for BotExecutor { - type Result = Option; - - fn handle(&mut self, r: BotDataRequest, _: &mut Self::Context) -> Self::Result { - let name = r.0; - let bot = &self.0; - - bot.bot_data(name) - } -} -- cgit v1.2.3-70-g09d2