Fix compilation errors on 0.14
This commit is contained in:
parent
0b7a7a0f02
commit
400c982639
3 changed files with 15 additions and 3 deletions
|
@ -18,7 +18,7 @@ fn main() {
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut reactor = IrcReactor::new().unwrap();
|
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();
|
client.identify().unwrap();
|
||||||
|
|
||||||
reactor.register_client_with_handler(client, move |client, message| {
|
reactor.register_client_with_handler(client, move |client, message| {
|
||||||
|
|
|
@ -137,10 +137,11 @@ impl IrcReactor {
|
||||||
pub fn register_client_with_handler<F, U>(
|
pub fn register_client_with_handler<F, U>(
|
||||||
&mut self, client: IrcClient, mut handler: F
|
&mut self, client: IrcClient, mut handler: F
|
||||||
) where F: FnMut(&IrcClient, Message) -> U + 'static,
|
) 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();
|
let handle = self.inner.handle().clone();
|
||||||
self.handlers.push(Box::new(client.stream().for_each(move |message| {
|
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(())
|
Ok(())
|
||||||
})));
|
})));
|
||||||
|
|
11
src/error.rs
11
src/error.rs
|
@ -11,6 +11,7 @@ use native_tls::Error as TlsError;
|
||||||
use serde_json::Error as JsonError;
|
use serde_json::Error as JsonError;
|
||||||
#[cfg(feature = "yaml")]
|
#[cfg(feature = "yaml")]
|
||||||
use serde_yaml::Error as YamlError;
|
use serde_yaml::Error as YamlError;
|
||||||
|
use tokio::executor::SpawnError;
|
||||||
use tokio_timer::TimerError;
|
use tokio_timer::TimerError;
|
||||||
#[cfg(feature = "toml")]
|
#[cfg(feature = "toml")]
|
||||||
use toml::de::Error as TomlReadError;
|
use toml::de::Error as TomlReadError;
|
||||||
|
@ -34,6 +35,10 @@ pub enum IrcError {
|
||||||
#[fail(display = "a TLS error occurred")]
|
#[fail(display = "a TLS error occurred")]
|
||||||
Tls(#[cause] TlsError),
|
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.
|
/// An internal synchronous channel closed.
|
||||||
#[fail(display = "a sync channel closed")]
|
#[fail(display = "a sync channel closed")]
|
||||||
SyncChannelClosed(#[cause] RecvError),
|
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 {
|
impl From<RecvError> for IrcError {
|
||||||
fn from(e: RecvError) -> IrcError {
|
fn from(e: RecvError) -> IrcError {
|
||||||
IrcError::SyncChannelClosed(e)
|
IrcError::SyncChannelClosed(e)
|
||||||
|
|
Loading…
Reference in a new issue