aboutsummaryrefslogtreecommitdiffstats
path: root/src/web_server/bot_executor.rs
diff options
context:
space:
mode:
authorJokler <jokler@protonmail.com>2020-10-15 13:11:54 +0000
committerGitHub <noreply@github.com>2020-10-15 13:11:54 +0000
commit43974717fee9a98701c6efa2e7221cdbfe7e537e (patch)
tree93fe1d75477ae3d1c8466611a2cedd7bed316aa2 /src/web_server/bot_executor.rs
parent23671b51b4e207574a63bce820acbf43169e2b6c (diff)
parent4e1c2b9f04073294ecb8402486c20d9c01721598 (diff)
downloadpokebot-43974717fee9a98701c6efa2e7221cdbfe7e537e.tar.gz
pokebot-43974717fee9a98701c6efa2e7221cdbfe7e537e.zip
Merge pull request #70 from Mavulp/actor-bots
Replace channels&locks with actors & log with slog
Diffstat (limited to 'src/web_server/bot_executor.rs')
-rw-r--r--src/web_server/bot_executor.rs63
1 files changed, 0 insertions, 63 deletions
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<MasterBot>);
-
-impl Actor for BotExecutor {
- type Context = Context<Self>;
-}
-
-pub struct BotNameListRequest;
-
-impl Message for BotNameListRequest {
- // A plain Vec does not work for some reason
- type Result = Result<Vec<String>, ()>;
-}
-
-impl Handler<BotNameListRequest> for BotExecutor {
- type Result = Result<Vec<String>, ()>;
-
- 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<Vec<BotData>, ()>;
-}
-
-impl Handler<BotDataListRequest> for BotExecutor {
- type Result = Result<Vec<BotData>, ()>;
-
- 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<BotData>;
-}
-
-impl Handler<BotDataRequest> for BotExecutor {
- type Result = Option<BotData>;
-
- fn handle(&mut self, r: BotDataRequest, _: &mut Self::Context) -> Self::Result {
- let name = r.0;
- let bot = &self.0;
-
- bot.bot_data(name)
- }
-}