diff --git a/irc-proto/src/command.rs b/irc-proto/src/command.rs index cb31821..387811a 100644 --- a/irc-proto/src/command.rs +++ b/irc-proto/src/command.rs @@ -1787,7 +1787,7 @@ impl FromStr for BatchSubCommand { #[cfg(test)] mod test { - use proto::Message; + use crate::Message; use super::Response; use super::Command; diff --git a/src/bin/build-bot.rs b/src/bin/build-bot.rs index effde57..bf464ed 100644 --- a/src/bin/build-bot.rs +++ b/src/bin/build-bot.rs @@ -18,7 +18,7 @@ fn main() { }; let mut reactor = IrcReactor::new().unwrap(); - let client = reactor.prepare_client_and_connect(&config).unwrap(); + let client = reactor.prepare_client_and_connect(config).unwrap(); client.identify().unwrap(); reactor.register_client_with_handler(client, move |client, message| { diff --git a/src/client/reactor.rs b/src/client/reactor.rs index 7b8e53f..13c897b 100644 --- a/src/client/reactor.rs +++ b/src/client/reactor.rs @@ -137,10 +137,11 @@ impl IrcReactor { pub fn register_client_with_handler( &mut self, client: IrcClient, mut handler: F ) where F: FnMut(&IrcClient, Message) -> U + 'static, - U: IntoFuture + 'static { + U: IntoFuture + 'static, + U::Future: Send { let handle = self.inner.handle().clone(); self.handlers.push(Box::new(client.stream().for_each(move |message| { - handle.spawn(handler(&client, message).into_future().map_err(|_| (()))); + handle.spawn(handler(&client, message).into_future().map_err(|_| (())))?; Ok(()) }))); diff --git a/src/error.rs b/src/error.rs index 7ced8f5..1284f63 100644 --- a/src/error.rs +++ b/src/error.rs @@ -11,6 +11,7 @@ use native_tls::Error as TlsError; use serde_json::Error as JsonError; #[cfg(feature = "yaml")] use serde_yaml::Error as YamlError; +use tokio::executor::SpawnError; use tokio_timer::TimerError; #[cfg(feature = "toml")] use toml::de::Error as TomlReadError; @@ -34,6 +35,10 @@ pub enum IrcError { #[fail(display = "a TLS error occurred")] Tls(#[cause] TlsError), + /// An error caused by Tokio being unable to spawn a task. + #[fail(display = "unable to spawn task")] + Spawn(#[cause] SpawnError), + /// An internal synchronous channel closed. #[fail(display = "a sync channel closed")] SyncChannelClosed(#[cause] RecvError), @@ -188,6 +193,12 @@ impl From for IrcError { } } +impl From for IrcError { + fn from(e: SpawnError) -> IrcError { + IrcError::Spawn(e) + } +} + impl From for IrcError { fn from(e: RecvError) -> IrcError { IrcError::SyncChannelClosed(e)