Cleaned up a bunch of code with clippy.

This commit is contained in:
Aaron Weiss 2018-01-28 01:14:55 +01:00
parent 90276b63b0
commit afe3558880
No known key found for this signature in database
GPG key ID: 047D32DF25DC22EF
8 changed files with 29 additions and 33 deletions

View file

@ -80,19 +80,19 @@ impl<'a> Future for ConnectionFuture<'a> {
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
match *self {
ConnectionFuture::Unsecured(ref config, ref mut inner) => {
ConnectionFuture::Unsecured(config, ref mut inner) => {
let framed = try_ready!(inner.poll()).framed(IrcCodec::new(config.encoding())?);
let transport = IrcTransport::new(config, framed);
Ok(Async::Ready(Connection::Unsecured(transport)))
}
ConnectionFuture::Secured(ref config, ref mut inner) => {
ConnectionFuture::Secured(config, ref mut inner) => {
let framed = try_ready!(inner.poll()).framed(IrcCodec::new(config.encoding())?);
let transport = IrcTransport::new(config, framed);
Ok(Async::Ready(Connection::Secured(transport)))
}
ConnectionFuture::Mock(ref config) => {
ConnectionFuture::Mock(config) => {
let enc: error::Result<_> = encoding_from_whatwg_label(
config.encoding()
).ok_or_else(|| io::Error::new(

View file

@ -38,7 +38,7 @@ use proto::Message;
/// all connected servers as the application runs. It can be used to run multiple servers on the
/// same thread, as well as to get better control over error management in an IRC client.
///
/// For a full example usage, see [irc::client::reactor](./index.html).
/// For a full example usage, see [`irc::client::reactor`](./index.html).
pub struct IrcReactor {
inner: Core,
handlers: Vec<Box<Future<Item = (), Error = error::Error>>>,

View file

@ -1,11 +1,11 @@
//! The primary API for communicating with an IRC server.
//!
//! This API provides the ability to connect to an IRC server via the
//! [IrcServer](struct.IrcServer.html) type. The [Server](trait.Server.html) trait that
//! [IrcServer](struct.IrcServer.html) implements provides methods for communicating with this
//! server. An extension trait, [ServerExt](./utils/trait.ServerExt.html), provides short-hand for
//! [`IrcServer`](struct.IrcServer.html) type. The [`Server`](trait.Server.html) trait that
//! [`IrcServer`](struct.IrcServer.html) implements provides methods for communicating with this
//! server. An extension trait, [`ServerExt`](./utils/trait.ServerExt.html), provides short-hand for
//! sending a variety of important messages without referring to their entries in
//! [proto::command](../../proto/command/enum.Command.html).
//! [`proto::command`](../../proto/command/enum.Command.html).
//!
//! # Examples
//!
@ -45,8 +45,6 @@
//! }).unwrap();
//! # }
//! ```
#[cfg(feature = "ctcp")]
use std::ascii::AsciiExt;
use std::collections::HashMap;
use std::path::Path;
use std::sync::{Arc, Mutex, RwLock};
@ -73,9 +71,9 @@ pub mod utils;
/// Trait extending all IRC streams with `for_each_incoming` convenience function.
///
/// This is typically used in conjunction with [Server::stream](trait.Server.html#tymethod.stream)
/// This is typically used in conjunction with [`Server::stream`](trait.Server.html#tymethod.stream)
/// in order to use an API akin to
/// [Server::for_each_incoming](trait.Server.html#method.for_each_incoming).
/// [`Server::for_each_incoming`](trait.Server.html#method.for_each_incoming).
///
/// # Example
///
@ -352,7 +350,6 @@ impl ServerState {
trace!("[RECV] {}", msg.to_string());
match msg.command {
JOIN(ref chan, _, _) => self.handle_join(msg.source_nickname().unwrap_or(""), chan),
/// This will panic if not specified.
PART(ref chan, _) => self.handle_part(msg.source_nickname().unwrap_or(""), chan),
QUIT(_) => self.handle_quit(msg.source_nickname().unwrap_or("")),
NICK(ref new_nick) => {
@ -595,12 +592,12 @@ impl ServerState {
///
/// The type itself provides a number of methods to create new connections, but most of the API
/// surface is in the form of the [Server](trait.Server.html) and
/// [ServerExt](./utils/trait.ServerExt.html) traits that provide methods of communicating with the
/// server after connection. Cloning an `IrcServer` is relatively cheap, as it's equivalent to
/// [`ServerExt`](./utils/trait.ServerExt.html) traits that provide methods of communicating with
/// the server after connection. Cloning an `IrcServer` is relatively cheap, as it's equivalent to
/// cloning a single `Arc`. This may be useful for setting up multiple threads with access to one
/// connection.
///
/// For a full example usage, see [irc::client::server](./index.html).
/// For a full example usage, see [`irc::client::server`](./index.html).
#[derive(Clone, Debug)]
pub struct IrcServer {
/// The internal, thread-safe server state.
@ -748,7 +745,7 @@ impl IrcServer {
/// [futures](http://docs.rs/futures). Additionally, you can find detailed tutorials on using
/// both libraries on the [tokio website](https://tokio.rs/docs/getting-started/tokio/). An easy
/// to use abstraction that does not require this knowledge is available via
/// [IrcReactors](../reactor/struct.IrcReactor.html).
/// [`IrcReactors`](../reactor/struct.IrcReactor.html).
///
/// # Example
/// ```no_run
@ -809,7 +806,7 @@ impl IrcServer {
/// use cases. To learn more, you can view the documentation for the
/// [futures](https://docs.rs/futures/) crate, or the tutorials for
/// [tokio](https://tokio.rs/docs/getting-started/futures/). An easy to use abstraction that does
/// not require this knowledge is available via [IrcReactors](../reactor/struct.IrcReactor.html).
/// not require this knowledge is available via [`IrcReactors`](../reactor/struct.IrcReactor.html).
#[derive(Debug)]
pub struct IrcServerFuture<'a> {
conn: ConnectionFuture<'a>,
@ -849,7 +846,7 @@ impl<'a> Future for IrcServerFuture<'a> {
///
/// This type should only be used by advanced users who are familiar with the implementation of this
/// crate. An easy to use abstraction that does not require this knowledge is available via
/// [IrcReactors](../reactor/struct.IrcReactor.html).
/// [`IrcReactors`](../reactor/struct.IrcReactor.html).
pub struct PackedIrcServer(pub IrcServer, pub Box<Future<Item = (), Error = error::Error>>);
#[cfg(test)]

View file

@ -1,8 +1,8 @@
//! Utilities and shortcuts for working with IRC servers.
//!
//! This module provides the [ServerExt](trait.ServerExt.html) trait which is the idiomatic way of
//! This module provides the [`ServerExt`](trait.ServerExt.html) trait which is the idiomatic way of
//! sending messages to an IRC server. This trait is automatically implemented for everything that
//! implements [Server](../trait.Server.html) and is designed to provide important functionality
//! implements [`Server`](../trait.Server.html) and is designed to provide important functionality
//! without clutter.
//!
//! # Examples

View file

@ -44,11 +44,11 @@ where
inner: inner,
burst_timer: tokio_timer::wheel().build(),
rolling_burst_window: VecDeque::new(),
burst_window_length: config.burst_window_length() as u64,
max_burst_messages: config.max_messages_in_burst() as u64,
burst_window_length: u64::from(config.burst_window_length()),
max_burst_messages: u64::from(config.max_messages_in_burst()),
current_burst_messages: 0,
ping_timer: timer.interval(Duration::from_secs(config.ping_time() as u64)),
ping_timeout: config.ping_timeout() as u64,
ping_timer: timer.interval(Duration::from_secs(u64::from(config.ping_time()))),
ping_timeout: u64::from(config.ping_timeout()),
last_ping_data: String::new(),
last_ping_sent: Instant::now(),
last_pong_received: Instant::now(),

View file

@ -1,7 +1,7 @@
//! A simple, thread-safe, and async-friendly library for IRC clients.
//!
//! # Quick Start
//! The main public API is entirely exported in [client::prelude](./client/prelude/index.html). This
//! The main public API is entirely exported in [`client::prelude`](./client/prelude/index.html). This
//! should include everything necessary to write an IRC client or bot.
//!
//! # A Whirlwind Tour
@ -11,7 +11,7 @@
//! implementation that could in principle be used in either client or server software. Both modules
//! feature a number of components that are low-level and can be used to build alternative APIs for
//! the IRC protocol. For the average user, the higher-level components for an IRC client are all
//! re-exported in [client::prelude](./client/prelude/index.html). That module serves as the best
//! re-exported in [`client::prelude`](./client/prelude/index.html). That module serves as the best
//! starting point for a new user trying to understand the high-level API.
//!
//! # Example
@ -72,7 +72,7 @@ pub mod client;
pub mod error;
pub mod proto;
const VERSION_STR: &'static str = concat!(
const VERSION_STR: &str = concat!(
env!("CARGO_PKG_NAME"),
":",
env!("CARGO_PKG_VERSION"),

View file

@ -1,5 +1,4 @@
//! Enumeration of all available client commands.
use std::ascii::AsciiExt;
use std::str::FromStr;
use error;

View file

@ -85,7 +85,7 @@ impl Message {
s.find('@'),
s.find('.'),
) {
(Some(i), _, _) => Some(&s[..i]), // <nick> '!' <user> [ '@' <host> ]
(Some(i), _, _) | // <nick> '!' <user> [ '@' <host> ]
(None, Some(i), _) => Some(&s[..i]), // <nick> '@' <host>
(None, None, None) => Some(s), // <nick>
_ => None, // <servername>
@ -223,7 +223,7 @@ impl FromStr for Message {
cmd
}
// If there's no arguments but the "command" starts with colon, it's not a command.
None if state.starts_with(":") => return Err(ErrorKind::InvalidCommand.into()),
None if state.starts_with(':') => return Err(ErrorKind::InvalidCommand.into()),
// If there's no arguments following the command, the rest of the state is the command.
None => {
let cmd = state;