Skip to content

Commit

Permalink
Add #[must_use] to Publish and refactor message ack calls
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ghtmare committed Jul 31, 2023
1 parent 78243d1 commit 2498525
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 2 additions & 1 deletion async-nats/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ impl From<tokio::sync::mpsc::error::SendError<Command>> for PublishError {
}
}

#[must_use]
pub struct Publish {
sender: mpsc::Sender<Command>,
subject: String,
Expand Down Expand Up @@ -79,7 +80,7 @@ impl IntoFuture for Publish {
type IntoFuture = Pin<Box<dyn Future<Output = Result<(), PublishError>> + Send>>;

fn into_future(self) -> Self::IntoFuture {
let sender = self.sender.clone();
let sender = self.sender;
let subject = self.subject;
let payload = self.payload;
let respond = self.respond;
Expand Down
6 changes: 2 additions & 4 deletions async-nats/src/jetstream/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ impl Message {
self.context
.client
.publish(reply.to_string(), "".into())
.into_future()
.map_err(Error::from)
.await
.map_err(Error::from)
} else {
Err(Box::new(std::io::Error::new(
std::io::ErrorKind::Other,
Expand Down Expand Up @@ -132,9 +131,8 @@ impl Message {
self.context
.client
.publish(reply.to_string(), kind.into())
.into_future()
.map_err(Error::from)
.await
.map_err(Error::from)
} else {
Err(Box::new(std::io::Error::new(
std::io::ErrorKind::Other,
Expand Down

0 comments on commit 2498525

Please sign in to comment.