aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugin.rs
diff options
context:
space:
mode:
authorJokler <jokler.contact@gmail.com>2018-02-12 20:14:46 +0100
committerJokler <jokler.contact@gmail.com>2018-02-12 20:14:46 +0100
commitd761a8ad9650b4797a673230c2cc924235aafc98 (patch)
treec2b1c6fee82ca216927a2580a33bd889de8bf9f9 /src/plugin.rs
parentda5c2c8e4893bfb095a8e2122b943c4dca61c41d (diff)
downloadfrippy-d761a8ad9650b4797a673230c2cc924235aafc98.tar.gz
frippy-d761a8ad9650b4797a673230c2cc924235aafc98.zip
Improve documentation
Diffstat (limited to 'src/plugin.rs')
-rw-r--r--src/plugin.rs22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/plugin.rs b/src/plugin.rs
index 88fe3ce..e343a2c 100644
--- a/src/plugin.rs
+++ b/src/plugin.rs
@@ -4,26 +4,33 @@ use std::fmt;
use irc::client::prelude::*;
use irc::error::IrcError;
+/// Describes if a [`Plugin`](trait.Plugin.html) is done working on a
+/// [`Message`](../../irc/proto/message/struct.Message.html) or if another thread is required.
+#[derive(Debug)]
pub enum ExecutionStatus {
+ /// The [`Plugin`](trait.Plugin.html) does not need to do any more work on this [`Message`](../../irc/proto/message/struct.Message.html).
Done,
+ /// An error occured during the execution.
Err(IrcError),
+ /// The execution needs to be done by [`execute_threaded()`](trait.Plugin.html#tymethod.execute_threaded).
RequiresThread,
}
/// `Plugin` has to be implemented for any struct that should be usable
-/// as a plugin in frippy.
+/// as a `Plugin` in frippy.
pub trait Plugin: PluginName + Send + Sync + fmt::Debug {
- /// This should return true if the `Plugin` wants to do work on the message.
+ /// 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, server: &IrcClient, message: &Message) -> ExecutionStatus;
- /// Handles messages which are not commands but still necessary.
+ /// Handles messages which are not commands in a new thread.
fn execute_threaded(&self, server: &IrcClient, message: &Message) -> Result<(), IrcError>;
/// Handles any command directed at this plugin.
fn command(&self, server: &IrcClient, command: PluginCommand) -> Result<(), IrcError>;
- /// Should work like command but return a String instead of sending messages to IRC.
+ /// Similar to [`command()`](trait.Plugin.html#tymethod.command) but return a String instead of sending messages directly to IRC.
fn evaluate(&self, server: &IrcClient, command: PluginCommand) -> Result<String, String>;
}
-/// `PluginName` is required by `Plugin`.
+/// `PluginName` is required by [`Plugin`](trait.Plugin.html).
///
/// To implement it simply add `#[derive(PluginName)]`
/// above the definition of the struct.
@@ -36,7 +43,7 @@ pub trait Plugin: PluginName + Send + Sync + fmt::Debug {
/// struct Foo;
/// ```
pub trait PluginName: Send + Sync + fmt::Debug {
- /// Returns the name of the plugin.
+ /// Returns the name of the `Plugin`.
fn name(&self) -> &str;
}
@@ -53,7 +60,8 @@ pub struct PluginCommand {
}
impl PluginCommand {
- /// Creates a `PluginCommand` from `Message` if it is a `PRIVMSG`
+ /// Creates a `PluginCommand` from [`Message`](../../irc/proto/message/struct.Message.html)
+ /// if it contains a [`PRIVMSG`](../../irc/proto/command/enum.Command.html#variant.PRIVMSG)
/// that starts with the provided `nick`.
pub fn from(nick: &str, message: &Message) -> Option<PluginCommand> {