From f3d679da59a64711ef96042668b26dffd1e662d5 Mon Sep 17 00:00:00 2001 From: Jokler Date: Sun, 29 Oct 2017 17:09:04 +0100 Subject: Add Database trait to be used by the Factoids plugin --- src/plugins/factoids/mod.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/plugins/factoids/mod.rs') diff --git a/src/plugins/factoids/mod.rs b/src/plugins/factoids/mod.rs index c69042f..a13bba6 100644 --- a/src/plugins/factoids/mod.rs +++ b/src/plugins/factoids/mod.rs @@ -4,16 +4,17 @@ use self::rlua::prelude::*; use irc::client::prelude::*; use irc::error::Error as IrcError; -use std::collections::HashMap; use std::sync::Mutex; use plugin::*; +mod database; +use self::database::*; static LUA_SANDBOX: &'static str = include_str!("sandbox.lua"); #[derive(PluginName, Debug)] -pub struct Factoids { - factoids: Mutex>, +pub struct Factoids { + factoids: Mutex, } macro_rules! try_lock { @@ -25,9 +26,9 @@ macro_rules! try_lock { } } -impl Factoids { - pub fn new() -> Factoids { - Factoids { factoids: Mutex::new(HashMap::new()) } +impl Factoids { + pub fn new(db: T) -> Factoids { + Factoids { factoids: Mutex::new(db) } } fn add(&self, server: &IrcServer, command: &mut PluginCommand) -> Result<(), IrcError> { @@ -128,7 +129,7 @@ impl Factoids { } } -impl Plugin for Factoids { +impl Plugin for Factoids { fn is_allowed(&self, _: &IrcServer, message: &Message) -> bool { match message.command { Command::PRIVMSG(_, ref content) => content.starts_with('!'), -- cgit v1.2.3-70-g09d2