summaryrefslogtreecommitdiffstats
path: root/src/plugin.rs
diff options
context:
space:
mode:
authorJokler <jokler.contact@gmail.com>2018-06-30 19:57:37 +0200
committerJokler <jokler.contact@gmail.com>2018-06-30 19:57:37 +0200
commit3929022952ffbd5be0a9ba4ff074a735dea2aed1 (patch)
tree0f2c3847f358c619059b151ea2c33bd2094063cd /src/plugin.rs
parent82ab100c7e6334dc6fa92e92c8838ecc622118d5 (diff)
downloadfrippy-3929022952ffbd5be0a9ba4ff074a735dea2aed1.tar.gz
frippy-3929022952ffbd5be0a9ba4ff074a735dea2aed1.zip
Plugins: Replace IrcClient with a trait
This is to make it simpler to replace the client in the future.
Diffstat (limited to 'src/plugin.rs')
-rw-r--r--src/plugin.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/plugin.rs b/src/plugin.rs
index 5538313..65bfe1f 100644
--- a/src/plugin.rs
+++ b/src/plugin.rs
@@ -20,17 +20,19 @@ pub enum ExecutionStatus {
/// `Plugin` has to be implemented for any struct that should be usable
/// as a `Plugin` in frippy.
pub trait Plugin: PluginName + Send + Sync + fmt::Debug {
+ type Client;
/// Handles messages which are not commands or returns
/// [`RequiresThread`](enum.ExecutionStatus.html#variant.RequiresThread)
/// if [`execute_threaded()`](trait.Plugin.html#tymethod.execute_threaded) should be used instead.
- fn execute(&self, client: &IrcClient, message: &Message) -> ExecutionStatus;
+ fn execute(&self, client: &Self::Client, message: &Message) -> ExecutionStatus;
/// Handles messages which are not commands in a new thread.
- fn execute_threaded(&self, client: &IrcClient, message: &Message) -> Result<(), FrippyError>;
+ fn execute_threaded(&self, client: &Self::Client, message: &Message)
+ -> Result<(), FrippyError>;
/// Handles any command directed at this plugin.
- fn command(&self, client: &IrcClient, command: PluginCommand) -> Result<(), FrippyError>;
+ fn command(&self, client: &Self::Client, command: PluginCommand) -> Result<(), FrippyError>;
/// Similar to [`command()`](trait.Plugin.html#tymethod.command) but return a String instead of
/// sending messages directly to IRC.
- fn evaluate(&self, client: &IrcClient, command: PluginCommand) -> Result<String, String>;
+ fn evaluate(&self, client: &Self::Client, command: PluginCommand) -> Result<String, String>;
}
/// `PluginName` is required by [`Plugin`](trait.Plugin.html).