Fixed clippy errors, complained about clippy errors and therefor disabled them, renamed toml_support to toml_config
This commit is contained in:
parent
504b5db297
commit
a38af8a22b
|
@ -7,6 +7,8 @@ license = "Unlicense"
|
|||
description = "IRC crate in Rust"
|
||||
repository = "https://git.karx.xyz/circe/async-circe.git"
|
||||
readme = "README.md"
|
||||
keywords = ["irc", "irc-crate", "async-irc"]
|
||||
categories = ["asynchronous", "network-programming"]
|
||||
|
||||
[dependencies.toml]
|
||||
version = "0.5"
|
||||
|
@ -38,7 +40,7 @@ version = "0.1"
|
|||
[features]
|
||||
default = ["tls"]
|
||||
tls = ["tokio-native-tls", "native-tls"]
|
||||
toml_support = ["toml", "serde", "serde_derive"]
|
||||
toml_config = ["toml", "serde", "serde_derive"]
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
all-features = true
|
||||
|
|
|
@ -10,4 +10,4 @@ features = ["macros", "rt"]
|
|||
|
||||
[dependencies.async-circe]
|
||||
path = "../.."
|
||||
features = ["toml_support"]
|
||||
features = ["toml_config"]
|
||||
|
|
48
src/lib.rs
48
src/lib.rs
|
@ -18,8 +18,8 @@
|
|||
//! # Ok(())
|
||||
//! }
|
||||
|
||||
#![warn(missing_docs)]
|
||||
#![allow(clippy::too_many_lines)]
|
||||
#![warn(missing_docs)] // We want everything documented
|
||||
#![allow(clippy::needless_return)] // Wants to remove a return statement, but when it's removed the code doesn't compile
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
|
||||
use tokio::io::BufReader;
|
||||
|
@ -30,11 +30,11 @@ use tokio::net::TcpStream;
|
|||
#[cfg(feature = "tls")]
|
||||
use native_tls::TlsConnector;
|
||||
|
||||
#[cfg(feature = "toml_support")]
|
||||
#[cfg(feature = "toml_config")]
|
||||
use serde_derive::Deserialize;
|
||||
#[cfg(feature = "toml_support")]
|
||||
#[cfg(feature = "toml_config")]
|
||||
use std::fs::File;
|
||||
#[cfg(feature = "toml_support")]
|
||||
#[cfg(feature = "toml_config")]
|
||||
use std::path::Path;
|
||||
|
||||
/// IRC comamnds
|
||||
|
@ -51,7 +51,7 @@ pub struct Client {
|
|||
|
||||
/// Config for the IRC client
|
||||
#[derive(Clone, Debug, Default)]
|
||||
#[cfg_attr(feature = "toml_support", derive(Deserialize))]
|
||||
#[cfg_attr(feature = "toml_config", derive(Deserialize))]
|
||||
pub struct Config {
|
||||
channels: Vec<String>,
|
||||
host: String,
|
||||
|
@ -142,20 +142,18 @@ impl Client {
|
|||
}
|
||||
|
||||
loop {
|
||||
if let Ok(ref command) = self.read().await {
|
||||
if let Some(command) = command {
|
||||
match command {
|
||||
commands::Command::PING(code) => {
|
||||
self.pong(code).await?;
|
||||
}
|
||||
commands::Command::OTHER(line) => {
|
||||
tracing::trace!("{}", line);
|
||||
if line.contains("001") {
|
||||
break;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
if let Some(command) = self.read().await? {
|
||||
match command {
|
||||
commands::Command::PING(code) => {
|
||||
self.pong(&code).await?;
|
||||
}
|
||||
commands::Command::OTHER(line) => {
|
||||
tracing::trace!("{}", line);
|
||||
if line.contains("001") {
|
||||
break;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +194,7 @@ impl Client {
|
|||
return Ok(None);
|
||||
}
|
||||
|
||||
Ok(Some(buffer.into()))
|
||||
Ok(Some(buffer))
|
||||
}
|
||||
|
||||
/// Read data coming from the IRC as a [`commands::Command`].
|
||||
|
@ -526,6 +524,7 @@ impl Config {
|
|||
/// "circe",
|
||||
/// );
|
||||
/// ```
|
||||
#[must_use]
|
||||
pub fn new(
|
||||
channels: &[&'static str],
|
||||
host: &str,
|
||||
|
@ -569,6 +568,7 @@ impl Config {
|
|||
}
|
||||
|
||||
/// Allows for configuring async-circe at runtime
|
||||
#[must_use]
|
||||
pub fn runtime_config(
|
||||
channels: Vec<String>,
|
||||
host: String,
|
||||
|
@ -580,14 +580,14 @@ impl Config {
|
|||
tracing::info!("New async-circe client config");
|
||||
let mode_config: Option<String>;
|
||||
if let Some(mode) = mode {
|
||||
mode_config = Some(mode.to_string());
|
||||
mode_config = Some(mode);
|
||||
} else {
|
||||
mode_config = None;
|
||||
}
|
||||
|
||||
let nickname_config: Option<String>;
|
||||
if let Some(nickname) = nickname {
|
||||
nickname_config = Some(nickname.to_string());
|
||||
nickname_config = Some(nickname);
|
||||
} else {
|
||||
nickname_config = Some(username.to_string());
|
||||
}
|
||||
|
@ -617,8 +617,8 @@ impl Config {
|
|||
/// # Errors
|
||||
/// Returns an Error if the file cannot be opened or if the TOML is invalid
|
||||
///
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "toml_support")))]
|
||||
#[cfg(feature = "toml_support")]
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "toml_config")))]
|
||||
#[cfg(feature = "toml_config")]
|
||||
pub fn from_toml<P: AsRef<Path>>(path: P) -> Result<Self, Error> {
|
||||
tracing::info!("New async-circe client config");
|
||||
use std::io::Read;
|
||||
|
|
Loading…
Reference in a new issue