aboutsummaryrefslogtreecommitdiffstats
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
parentda5c2c8e4893bfb095a8e2122b943c4dca61c41d (diff)
downloadfrippy-d761a8ad9650b4797a673230c2cc924235aafc98.tar.gz
frippy-d761a8ad9650b4797a673230c2cc924235aafc98.zip
Improve documentation
-rw-r--r--src/lib.rs14
-rw-r--r--src/plugin.rs22
2 files changed, 21 insertions, 15 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 8a3a0d1..87c06c3 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -59,7 +59,7 @@ pub struct Bot {
impl Bot {
/// Creates a `Bot`.
- /// By itself the bot only responds to a few simple ctcp commands
+ /// By itself the bot only responds to a few simple CTCP commands
/// defined per config file.
/// Any other functionality has to be provided by plugins
/// which need to implement [`Plugin`](plugin/trait.Plugin.html).
@@ -73,7 +73,7 @@ impl Bot {
Bot { plugins: ThreadedPlugins::new() }
}
- /// Adds the plugin.
+ /// Adds the [`Plugin`](plugin/trait.Plugin.html).
/// These plugins will be used to evaluate incoming messages from IRC.
///
/// # Examples
@@ -87,7 +87,7 @@ impl Bot {
self.plugins.add(plugin);
}
- /// Removes a plugin based on its name.
+ /// Removes a [`Plugin`](plugin/trait.Plugin.html) based on its name.
/// The binary currently uses this to disable plugins
/// based on user configuration.
///
@@ -103,12 +103,10 @@ impl Bot {
self.plugins.remove(name)
}
- /// This connects the `Bot` to IRC and creates a task on the `IrcReactor`
- /// which returns an Ok if the connection was cleanly closed and an Err
- /// if the connection was lostwhich returns an Ok if the connection was cleanly closed and an Err
- /// if the connection was lost.
+ /// This connects the `Bot` to IRC and creates a task on the [`IrcReactor`](../irc/client/reactor/struct.IrcReactor.html)
+ /// which returns an Ok if the connection was cleanly closed and an Err if the connection was lost.
///
- /// You need to run the `IrcReactor`, so that the `Bot`
+ /// You need to run the [`IrcReactor`](../irc/client/reactor/struct.IrcReactor.html), so that the `Bot`
/// can actually do its work.
///
/// # Examples
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> {