diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4f8833b..1cbf32a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,6 +16,7 @@ jobs: with: profile: minimal toolchain: stable + components: clippy override: true - name: Install ZeroMQ @@ -30,3 +31,14 @@ jobs: uses: actions-rs/cargo@v1 with: command: test + + - name: cargo doc + uses: actions-rs/cargo@v1 + with: + command: doc + + - name: clippy check + uses: actions-rs/clippy-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --all-features -- -D warnings diff --git a/src/dealer.rs b/src/dealer.rs index c4f03da..427c0ec 100644 --- a/src/dealer.rs +++ b/src/dealer.rs @@ -44,7 +44,7 @@ pub struct Dealer + Unpin, T: Into>(Broker) impl + Unpin, T: Into> Dealer { /// Represent as `Socket` from zmq crate in case you want to call its methods. pub fn as_raw_socket(&self) -> &zmq::Socket { - &self.0.socket.as_socket() + self.0.socket.as_socket() } } diff --git a/src/pair.rs b/src/pair.rs index 184baf7..835c1f4 100644 --- a/src/pair.rs +++ b/src/pair.rs @@ -49,7 +49,7 @@ pub struct Pair + Unpin, T: Into>(Broker); impl + Unpin, T: Into> Pair { /// Represent as `Socket` from zmq crate in case you want to call its methods. pub fn as_raw_socket(&self) -> &zmq::Socket { - &self.0.socket.as_socket() + self.0.socket.as_socket() } } diff --git a/src/publish.rs b/src/publish.rs index 0959de8..370dc6d 100644 --- a/src/publish.rs +++ b/src/publish.rs @@ -49,7 +49,7 @@ pub struct Publish + Unpin, T: Into>(Sender impl + Unpin, T: Into> Publish { /// Represent as `Socket` from zmq crate in case you want to call its methods. pub fn as_raw_socket(&self) -> &zmq::Socket { - &self.0.socket.as_socket() + self.0.socket.as_socket() } } diff --git a/src/pull.rs b/src/pull.rs index f33ea62..0eefcb8 100644 --- a/src/pull.rs +++ b/src/pull.rs @@ -51,7 +51,7 @@ pub struct Pull(Receiver); impl Pull { /// Represent as `Socket` from zmq crate in case you want to call its methods. pub fn as_raw_socket(&self) -> &zmq::Socket { - &self.0.socket.as_socket() + self.0.socket.as_socket() } } diff --git a/src/push.rs b/src/push.rs index d525156..6709eef 100644 --- a/src/push.rs +++ b/src/push.rs @@ -48,7 +48,7 @@ pub struct Push + Unpin, T: Into>(Sender); impl + Unpin, T: Into> Push { /// Represent as `Socket` from zmq crate in case you want to call its methods. pub fn as_raw_socket(&self) -> &zmq::Socket { - &self.0.socket.as_socket() + self.0.socket.as_socket() } } diff --git a/src/reactor/mod.rs b/src/reactor/mod.rs index 832ade4..d8b3dae 100644 --- a/src/reactor/mod.rs +++ b/src/reactor/mod.rs @@ -2,12 +2,12 @@ pub(crate) mod evented; mod watcher; -pub(crate) use watcher::Watcher; use crate::socket::{Multipart, MultipartIter}; +pub(crate) use watcher::Watcher; use futures::ready; -use std::task::{Context, Poll}; use std::io::{self, ErrorKind}; +use std::task::{Context, Poll}; use zmq::Error; /// Trait to get the raw zmq socket. @@ -23,7 +23,7 @@ impl ZmqSocket { if self.as_socket().get_events()?.contains(event) { Ok(()) } else { - Err(io::Error::new(ErrorKind::WouldBlock,Error::EAGAIN)) + Err(io::Error::new(ErrorKind::WouldBlock, Error::EAGAIN)) } } @@ -32,22 +32,20 @@ impl ZmqSocket { cx: &mut Context<'_>, buffer: &mut MultipartIter, ) -> Poll> { - let _ = ready!(self.poll_write_with(cx, |_| { - self.poll_event(zmq::POLLOUT) - })); + let _ = ready!(self.poll_write_with(cx, |_| { self.poll_event(zmq::POLLOUT) })); //ready!()?; let mut buffer = buffer.0.by_ref().peekable(); while let Some(msg) = buffer.next() { let mut flags = zmq::DONTWAIT; - if let Some(_) = buffer.peek() { + if buffer.peek().is_some() { flags |= zmq::SNDMORE; } match self.as_socket().send(msg, flags) { Ok(_) => {} Err(Error::EAGAIN) => return Poll::Pending, - Err(e) => return Poll::Ready(Err(e.into())), + Err(e) => return Poll::Ready(Err(e)), } } @@ -55,9 +53,7 @@ impl ZmqSocket { } pub(crate) fn recv(&self, cx: &mut Context<'_>) -> Poll> { - let _ = ready!(self.poll_read_with(cx, |_| { - self.poll_event(zmq::POLLIN) - })); + let _ = ready!(self.poll_read_with(cx, |_| { self.poll_event(zmq::POLLIN) })); let mut buffer = Vec::new(); let mut more = true; @@ -69,7 +65,7 @@ impl ZmqSocket { more = msg.get_more(); buffer.push(msg); } - Err(e) => return Poll::Ready(Err(e.into())), + Err(e) => return Poll::Ready(Err(e)), } } diff --git a/src/reply.rs b/src/reply.rs index 9814338..34b79b1 100644 --- a/src/reply.rs +++ b/src/reply.rs @@ -80,14 +80,14 @@ impl + Unpin, T: Into> Reply { msg: S, ) -> Result<(), RequestReplyError> { let mut msg = msg.into(); - let res = poll_fn(move |cx| self.inner.socket.send(cx, &mut msg)).await?; + poll_fn(move |cx| self.inner.socket.send(cx, &mut msg)).await?; self.received.store(false, Ordering::Relaxed); - Ok(res) + Ok(()) } /// Represent as `Socket` from zmq crate in case you want to call its methods. pub fn as_raw_socket(&self) -> &zmq::Socket { - &self.inner.socket.as_socket() + self.inner.socket.as_socket() } } diff --git a/src/request.rs b/src/request.rs index 7887c01..47fe3bb 100644 --- a/src/request.rs +++ b/src/request.rs @@ -65,9 +65,9 @@ impl + Unpin, T: Into> Request { msg: S, ) -> Result<(), RequestReplyError> { let mut msg = msg.into(); - let res = poll_fn(move |cx| self.inner.socket.send(cx, &mut msg)).await?; + poll_fn(move |cx| self.inner.socket.send(cx, &mut msg)).await?; self.received.store(false, Ordering::Relaxed); - Ok(res) + Ok(()) } /// Receive reply from REP/ROUTER socket. [`send`](#method.send) must be called first in order to receive reply. @@ -79,6 +79,6 @@ impl + Unpin, T: Into> Request { /// Represent as `Socket` from zmq crate in case you want to call its methods. pub async fn as_raw_socket(&self) -> &zmq::Socket { - &self.inner.socket.as_socket() + self.inner.socket.as_socket() } } diff --git a/src/router.rs b/src/router.rs index beec4f6..bf27ffe 100644 --- a/src/router.rs +++ b/src/router.rs @@ -42,7 +42,7 @@ pub struct Router + Unpin, T: Into>(Broker) impl + Unpin, T: Into> Router { /// Represent as `Socket` from zmq crate in case you want to call its methods. pub fn as_raw_socket(&self) -> &zmq::Socket { - &self.0.socket.as_socket() + self.0.socket.as_socket() } } diff --git a/src/socket.rs b/src/socket.rs index d1ef19e..c3d7a3e 100644 --- a/src/socket.rs +++ b/src/socket.rs @@ -110,7 +110,7 @@ impl + Unpin, T: Into> Sink> } fn start_send(self: Pin<&mut Self>, item: MultipartIter) -> Result<(), Self::Error> { - self.get_mut().buffer = Some(item.into()); + self.get_mut().buffer = Some(item); Ok(()) } diff --git a/src/stream.rs b/src/stream.rs index 1a22c8c..3aa2c0c 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -69,6 +69,6 @@ impl Stream for ZmqStream { impl ZmqStream { /// Represent as `Socket` from zmq crate in case you want to call its methods. pub fn as_raw_socket(&self) -> &zmq::Socket { - &self.0.socket.as_socket() + self.0.socket.as_socket() } } diff --git a/src/subscribe.rs b/src/subscribe.rs index b690cc3..d914262 100644 --- a/src/subscribe.rs +++ b/src/subscribe.rs @@ -84,6 +84,6 @@ impl Subscribe { /// Represent as `Socket` from zmq crate in case you want to call its methods. pub fn as_raw_socket(&self) -> &zmq::Socket { - &self.0.socket.as_socket() + self.0.socket.as_socket() } } diff --git a/src/xpublish.rs b/src/xpublish.rs index 93f00f3..86c8d07 100644 --- a/src/xpublish.rs +++ b/src/xpublish.rs @@ -50,7 +50,7 @@ pub struct XPublish + Unpin, T: Into>(Broker + Unpin, T: Into> XPublish { /// Represent as `Socket` from zmq crate in case you want to call its methods. pub fn as_raw_socket(&self) -> &zmq::Socket { - &self.0.socket.as_socket() + self.0.socket.as_socket() } } diff --git a/src/xsubscribe.rs b/src/xsubscribe.rs index 35176e3..5d5f3ae 100644 --- a/src/xsubscribe.rs +++ b/src/xsubscribe.rs @@ -84,6 +84,6 @@ impl XSubscribe { /// Represent as `Socket` from zmq crate in case you want to call its methods. pub fn as_raw_socket(&self) -> &zmq::Socket { - &self.0.socket.as_socket() + self.0.socket.as_socket() } }