Skip to content

Commit

Permalink
Clippy warnings (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Mar 24, 2024
1 parent 47c091b commit 5912642
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 113 deletions.
8 changes: 3 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ edition = "2021"
features = ["ntex/tokio"]

[dependencies]
ntex = "1.0"
ntex = "1.2"
bitflags = "2.4"
log = "0.4"
pin-project-lite = "0.2"
Expand All @@ -25,9 +25,7 @@ thiserror = "1.0"

[dev-dependencies]
env_logger = "0.11"
ntex-tls = "1.0"
rustls = "0.21"
rustls-pemfile = "1.0"
ntex-tls = "1.1"
openssl = "0.10"
test-case = "3.2"
ntex = { version = "1.0", features = ["tokio", "rustls", "openssl"] }
ntex = { version = "1.2", features = ["tokio", "openssl"] }
2 changes: 1 addition & 1 deletion examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async fn main() -> std::io::Result<()> {
std::env::set_var("RUST_LOG", "ntex=trace,ntex_mqtt=trace,basic=trace");
env_logger::init();

ntex::server::Server::build()
ntex::server::build()
.bind("mqtt", "127.0.0.1:1883", |_| {
MqttServer::new()
.v3(v3::MqttServer::new(handshake_v3).publish(publish_v3))
Expand Down
6 changes: 1 addition & 5 deletions examples/mqtt-ws-client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ async fn main() -> std::io::Result<()> {
});
ntex::rt::spawn(router.start_default());

let _ack = sink
.publish("test-topic", Bytes::from_static(b"data"))
.send_at_least_once()
.await
.unwrap();
sink.publish("test-topic", Bytes::from_static(b"data")).send_at_least_once().await.unwrap();
println!("ack is received");

sleep(Millis(10_000)).await;
Expand Down
2 changes: 1 addition & 1 deletion examples/openssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async fn main() -> std::io::Result<()> {
builder.set_certificate_chain_file("./tests/cert.pem").unwrap();
let acceptor = builder.build();

ntex::server::Server::build()
ntex::server::build()
.bind("mqtt", "127.0.0.1:8883", move |_| {
chain_factory(SslAcceptor::new(acceptor.clone()))
.map_err(|_err| MqttError::Service(ServerError {}))
Expand Down
2 changes: 1 addition & 1 deletion examples/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async fn main() -> std::io::Result<()> {
std::env::set_var("RUST_LOG", "ntex=trace,ntex_mqtt=trace,routing=trace");
env_logger::init();

ntex::server::Server::build()
ntex::server::build()
.bind("mqtt", "127.0.0.1:1883", |_| {
v3::MqttServer::new(|handshake: v3::Handshake| async move {
log::info!("new mqtt v3 connection: {:?}", handshake);
Expand Down
2 changes: 1 addition & 1 deletion examples/routing_v5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async fn main() -> std::io::Result<()> {
std::env::set_var("RUST_LOG", "ntex=trace,ntex_mqtt=trace,routing_v5=trace");
env_logger::init();

ntex::server::Server::build()
ntex::server::build()
.bind("mqtt", "127.0.0.1:1883", |_| {
v5::MqttServer::new(
fn_service(|handshake: v5::Handshake| async move {
Expand Down
88 changes: 0 additions & 88 deletions examples/rustls.rs

This file was deleted.

2 changes: 1 addition & 1 deletion examples/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async fn main() -> std::io::Result<()> {

log::info!("Hello");

ntex::server::Server::build()
ntex::server::build()
.bind("mqtt", "127.0.0.1:1883", |_| {
MqttServer::new()
.v3(v3::MqttServer::new(handshake_v3).publish(fn_factory_with_config(
Expand Down
2 changes: 1 addition & 1 deletion examples/subs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ async fn main() -> std::io::Result<()> {
std::env::set_var("RUST_LOG", "ntex=trace,ntex_mqtt=trace,subs=trace");
env_logger::init();

ntex::server::Server::build()
ntex::server::build()
.bind("mqtt", "127.0.0.1:1883", |_| {
MqttServer::new(handshake)
.control(control_service_factory())
Expand Down
3 changes: 2 additions & 1 deletion src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@ where
let codec = this.codec.clone();
let state = inner.state.clone();
let fut = this.service.call_static(item);
ntex::rt::spawn(async move {
#[allow(clippy::let_underscore_future)]
let _ = ntex::rt::spawn(async move {
let item = fut.await;
state.borrow_mut().handle_result(
item,
Expand Down
13 changes: 9 additions & 4 deletions src/v3/client/connection.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::let_underscore_future)]
use std::{fmt, marker::PhantomData, rc::Rc};

use ntex::io::{DispatcherConfig, IoBoxed};
Expand Down Expand Up @@ -95,7 +96,8 @@ impl Client {
/// Default handler closes connection on any control message.
pub async fn start_default(self) {
if self.keepalive.non_zero() {
ntex::rt::spawn(keepalive(MqttSink::new(self.shared.clone()), self.keepalive));
let _ =
ntex::rt::spawn(keepalive(MqttSink::new(self.shared.clone()), self.keepalive));
}

let dispatcher = create_dispatcher(
Expand All @@ -116,7 +118,8 @@ impl Client {
S: Service<ControlMessage<E>, Response = ControlResult, Error = E> + 'static,
{
if self.keepalive.non_zero() {
ntex::rt::spawn(keepalive(MqttSink::new(self.shared.clone()), self.keepalive));
let _ =
ntex::rt::spawn(keepalive(MqttSink::new(self.shared.clone()), self.keepalive));
}

let dispatcher = create_dispatcher(
Expand Down Expand Up @@ -179,7 +182,8 @@ where
/// Run client with default control messages handler
pub async fn start_default(self) {
if self.keepalive.non_zero() {
ntex::rt::spawn(keepalive(MqttSink::new(self.shared.clone()), self.keepalive));
let _ =
ntex::rt::spawn(keepalive(MqttSink::new(self.shared.clone()), self.keepalive));
}

let dispatcher = create_dispatcher(
Expand All @@ -199,7 +203,8 @@ where
S: Service<ControlMessage<Err>, Response = ControlResult, Error = Err> + 'static,
{
if self.keepalive.non_zero() {
ntex::rt::spawn(keepalive(MqttSink::new(self.shared.clone()), self.keepalive));
let _ =
ntex::rt::spawn(keepalive(MqttSink::new(self.shared.clone()), self.keepalive));
}

let dispatcher = create_dispatcher(
Expand Down
13 changes: 9 additions & 4 deletions src/v5/client/connection.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::let_underscore_future)]
use std::{cell::RefCell, fmt, marker, num::NonZeroU16, rc::Rc};

use ntex::io::{DispatcherConfig, IoBoxed};
Expand Down Expand Up @@ -104,7 +105,8 @@ impl Client {
/// Default handler closes connection on any control message.
pub async fn start_default(self) {
if self.keepalive.non_zero() {
ntex::rt::spawn(keepalive(MqttSink::new(self.shared.clone()), self.keepalive));
let _ =
ntex::rt::spawn(keepalive(MqttSink::new(self.shared.clone()), self.keepalive));
}

let dispatcher = create_dispatcher(
Expand All @@ -128,7 +130,8 @@ impl Client {
S: Service<ControlMessage<E>, Response = ControlResult, Error = E> + 'static,
{
if self.keepalive.non_zero() {
ntex::rt::spawn(keepalive(MqttSink::new(self.shared.clone()), self.keepalive));
let _ =
ntex::rt::spawn(keepalive(MqttSink::new(self.shared.clone()), self.keepalive));
}

let dispatcher = create_dispatcher(
Expand Down Expand Up @@ -193,7 +196,8 @@ where
/// Run client with default control messages handler
pub async fn start_default(self) {
if self.keepalive.non_zero() {
ntex::rt::spawn(keepalive(MqttSink::new(self.shared.clone()), self.keepalive));
let _ =
ntex::rt::spawn(keepalive(MqttSink::new(self.shared.clone()), self.keepalive));
}

let dispatcher = create_dispatcher(
Expand All @@ -216,7 +220,8 @@ where
S: Service<ControlMessage<Err>, Response = ControlResult, Error = Err> + 'static,
{
if self.keepalive.non_zero() {
ntex::rt::spawn(keepalive(MqttSink::new(self.shared.clone()), self.keepalive));
let _ =
ntex::rt::spawn(keepalive(MqttSink::new(self.shared.clone()), self.keepalive));
}

let dispatcher = create_dispatcher(
Expand Down

0 comments on commit 5912642

Please sign in to comment.