Fix compilation errors on 0.14

This commit is contained in:
Adam Gausmann 2019-06-10 20:52:36 -05:00
parent 0b7a7a0f02
commit 400c982639
3 changed files with 15 additions and 3 deletions

View file

@ -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| {

View file

@ -137,10 +137,11 @@ impl IrcReactor {
pub fn register_client_with_handler<F, U>(
&mut self, client: IrcClient, mut handler: F
) where F: FnMut(&IrcClient, Message) -> U + 'static,
U: IntoFuture<Item = (), Error = error::IrcError> + 'static {
U: IntoFuture<Item = (), Error = error::IrcError> + '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(())
})));

View file

@ -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<TlsError> for IrcError {
}
}
impl From<SpawnError> for IrcError {
fn from(e: SpawnError) -> IrcError {
IrcError::Spawn(e)
}
}
impl From<RecvError> for IrcError {
fn from(e: RecvError) -> IrcError {
IrcError::SyncChannelClosed(e)