Skip to content

Commit

Permalink
feat: remove validation on Subscribe::new_many() (#422)
Browse files Browse the repository at this point in the history
Reverts #392 as the feature is deemed unnecessary.

Signed-off-by: Devdutt Shenoi <devdutt@bytebeam.io>
  • Loading branch information
de-sh authored Aug 10, 2022
1 parent 9c83d89 commit d482927
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
----------------
rumqttc
-----------
- Change variants in `ClientError` to not expose dependence on flume/`SendError`.
----------
- Change variants in `ClientError` to not expose dependence on flume/`SendError` (#420)
- Revert erroring out when Subscription filter list is empty (#422).

-----------

Expand Down
8 changes: 3 additions & 5 deletions rumqttc/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! This module offers a high level synchronous and asynchronous abstraction to
//! async eventloop.
use crate::mqttbytes::{self, v4::*, QoS};
use crate::mqttbytes::{v4::*, QoS};
use crate::{ConnectionError, Event, EventLoop, MqttOptions, Request};

use bytes::Bytes;
Expand All @@ -18,8 +18,6 @@ pub enum ClientError {
Request(Request),
#[error("Failed to send mqtt requests to eventloop")]
TryRequest(Request),
#[error("Serialization error: {0}")]
Mqtt4(#[from] mqttbytes::Error),
}

impl From<SendError<()>> for ClientError {
Expand Down Expand Up @@ -168,7 +166,7 @@ impl AsyncClient {
where
T: IntoIterator<Item = SubscribeFilter>,
{
let subscribe = Subscribe::new_many(topics)?;
let subscribe = Subscribe::new_many(topics);
let request = Request::Subscribe(subscribe);
self.request_tx.send_async(request).await?;
Ok(())
Expand All @@ -179,7 +177,7 @@ impl AsyncClient {
where
T: IntoIterator<Item = SubscribeFilter>,
{
let subscribe = Subscribe::new_many(topics)?;
let subscribe = Subscribe::new_many(topics);
let request = Request::Subscribe(subscribe);
self.request_tx.try_send(request)?;
Ok(())
Expand Down
7 changes: 2 additions & 5 deletions rumqttc/src/mqttbytes/v4/subscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,13 @@ impl Subscribe {
}
}

pub fn new_many<T>(topics: T) -> Result<Subscribe, Error>
pub fn new_many<T>(topics: T) -> Subscribe
where
T: IntoIterator<Item = SubscribeFilter>,
{
let filters: Vec<SubscribeFilter> = topics.into_iter().collect();

match filters.len() {
0 => Err(Error::EmptySubscription),
_ => Ok(Subscribe { pkid: 0, filters }),
}
Subscribe { pkid: 0, filters }
}

pub fn add(&mut self, path: String, qos: QoS) -> &mut Self {
Expand Down

0 comments on commit d482927

Please sign in to comment.