Skip to content

Commit

Permalink
Replace ZERO with Duration::ZERO
Browse files Browse the repository at this point in the history
  • Loading branch information
rmqtt committed Jul 21, 2023
1 parent 6b06ec3 commit 2def0dc
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions rmqtt-bin/src/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ use std::pin::Pin;
use std::task::{Context, Poll};
use std::{
io::{self, ErrorKind},
marker, time,
marker,
time::Duration,
};

use rmqtt::futures::{ready, FutureExt, Sink, Stream};
Expand All @@ -22,15 +23,13 @@ use rmqtt::tokio_tungstenite::tungstenite::Message;
use rmqtt::tokio_tungstenite::WebSocketStream;
use rmqtt::{log, MqttError};

pub(self) const ZERO: std::time::Duration = std::time::Duration::from_millis(0);

pub struct WSServer<T> {
timeout: time::Duration,
timeout: Duration,
io: marker::PhantomData<T>,
}

impl<T: AsyncRead + AsyncWrite> WSServer<T> {
pub fn new(timeout: time::Duration) -> Self {
pub fn new(timeout: Duration) -> Self {
WSServer { timeout, io: marker::PhantomData }
}
}
Expand Down Expand Up @@ -58,7 +57,7 @@ impl<T: AsyncRead + AsyncWrite + Unpin + 'static> ServiceFactory for WSServer<T>

pub struct WSService<T> {
io: marker::PhantomData<T>,
timeout: time::Duration,
timeout: Duration,
}

impl<T: AsyncRead + AsyncWrite + Unpin + 'static> Service for WSService<T> {
Expand All @@ -76,7 +75,7 @@ impl<T: AsyncRead + AsyncWrite + Unpin + 'static> Service for WSService<T> {
fn call(&self, req: Self::Request) -> Self::Future {
WSServiceFut {
fut: accept_hdr_async(req, on_handshake).boxed_local(),
delay: if self.timeout == ZERO { None } else { Some(sleep(self.timeout)) },
delay: if self.timeout == Duration::ZERO { None } else { Some(sleep(self.timeout)) },
}
}
}
Expand Down

0 comments on commit 2def0dc

Please sign in to comment.