Skip to content

Commit

Permalink
Add clippy github action
Browse files Browse the repository at this point in the history
  • Loading branch information
rdelfin committed Jul 30, 2023
1 parent d3434ea commit 2c8fb40
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 29 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
with:
profile: minimal
toolchain: stable
components: clippy
override: true

- name: Install ZeroMQ
Expand All @@ -30,3 +31,14 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: test

- name: cargo doc
uses: actions-rs/cargo@v1
with:
command: doc

- nmae: clippy check
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: -D warnings --all-features
2 changes: 1 addition & 1 deletion src/dealer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub struct Dealer<I: Iterator<Item = T> + Unpin, T: Into<Message>>(Broker<I, T>)
impl<I: Iterator<Item = T> + Unpin, T: Into<Message>> Dealer<I, T> {
/// 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()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub struct Pair<I: Iterator<Item = T> + Unpin, T: Into<Message>>(Broker<I, T>);
impl<I: Iterator<Item = T> + Unpin, T: Into<Message>> Pair<I, T> {
/// 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()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub struct Publish<I: Iterator<Item = T> + Unpin, T: Into<Message>>(Sender<I, T>
impl<I: Iterator<Item = T> + Unpin, T: Into<Message>> Publish<I, T> {
/// 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()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/pull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub struct Push<I: Iterator<Item = T> + Unpin, T: Into<Message>>(Sender<I, T>);
impl<I: Iterator<Item = T> + Unpin, T: Into<Message>> Push<I, T> {
/// 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()
}
}

Expand Down
20 changes: 8 additions & 12 deletions src/reactor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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))
}
}

Expand All @@ -32,32 +32,28 @@ impl ZmqSocket {
cx: &mut Context<'_>,
buffer: &mut MultipartIter<I, T>,
) -> Poll<Result<(), Error>> {
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)),
}
}

Poll::Ready(Ok(()))
}

pub(crate) fn recv(&self, cx: &mut Context<'_>) -> Poll<Result<Multipart, Error>> {
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;
Expand All @@ -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)),
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/reply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ impl<I: Iterator<Item = T> + Unpin, T: Into<Message>> Reply<I, T> {
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()
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ impl<I: Iterator<Item = T> + Unpin, T: Into<Message>> Request<I, T> {
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.
Expand All @@ -79,6 +79,6 @@ impl<I: Iterator<Item = T> + Unpin, T: Into<Message>> Request<I, T> {

/// 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()
}
}
2 changes: 1 addition & 1 deletion src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub struct Router<I: Iterator<Item = T> + Unpin, T: Into<Message>>(Broker<I, T>)
impl<I: Iterator<Item = T> + Unpin, T: Into<Message>> Router<I, T> {
/// 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()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl<I: Iterator<Item = T> + Unpin, T: Into<Message>> Sink<MultipartIter<I, T>>
}

fn start_send(self: Pin<&mut Self>, item: MultipartIter<I, T>) -> Result<(), Self::Error> {
self.get_mut().buffer = Some(item.into());
self.get_mut().buffer = Some(item);
Ok(())
}

Expand Down
2 changes: 1 addition & 1 deletion src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
2 changes: 1 addition & 1 deletion src/subscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
2 changes: 1 addition & 1 deletion src/xpublish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub struct XPublish<I: Iterator<Item = T> + Unpin, T: Into<Message>>(Broker<I, T
impl<I: Iterator<Item = T> + Unpin, T: Into<Message>> XPublish<I, T> {
/// 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()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/xsubscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

0 comments on commit 2c8fb40

Please sign in to comment.