Merge pull request #180 from AGausmann/compile-fixes

Fix compilation errors on 0.14
This commit is contained in:
Aaron Weiss 2019-06-13 11:50:27 -04:00 committed by GitHub
commit 9bb7fa8ba2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 4 deletions

View file

@ -1787,7 +1787,7 @@ impl FromStr for BatchSubCommand {
#[cfg(test)]
mod test {
use proto::Message;
use crate::Message;
use super::Response;
use super::Command;

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)