Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions rumqttc/src/v5/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@ impl AsyncClient {
S: Into<String>,
P: Into<Bytes>,
{
let topic = topic.into();
let mut publish = Publish::new(&topic, qos, payload, properties);
let topic: String = topic.into();
let topic_valid = valid_topic(&topic);
let topic_bytes = Bytes::from(topic.into_bytes());
let mut publish = Publish::new(topic_bytes, qos, payload, properties);
publish.retain = retain;
let publish = Request::Publish(publish);
if !valid_topic(&topic) {
if !topic_valid {
return Err(ClientError::Request(publish));
}
self.request_tx.send_async(publish).await?;
Expand Down Expand Up @@ -137,11 +139,13 @@ impl AsyncClient {
S: Into<String>,
P: Into<Bytes>,
{
let topic = topic.into();
let mut publish = Publish::new(&topic, qos, payload, properties);
let topic: String = topic.into();
let topic_valid = valid_topic(&topic);
let topic_bytes = Bytes::from(topic.into_bytes());
let mut publish = Publish::new(topic_bytes, qos, payload, properties);
publish.retain = retain;
let publish = Request::Publish(publish);
if !valid_topic(&topic) {
if !topic_valid {
return Err(ClientError::TryRequest(publish));
}
self.request_tx.try_send(publish)?;
Expand Down Expand Up @@ -208,11 +212,13 @@ impl AsyncClient {
where
S: Into<String>,
{
let topic = topic.into();
let mut publish = Publish::new(&topic, qos, payload, properties);
let topic: String = topic.into();
let topic_valid = valid_topic(&topic);
let topic_bytes = Bytes::from(topic.into_bytes());
let mut publish = Publish::new(topic_bytes, qos, payload, properties);
publish.retain = retain;
let publish = Request::Publish(publish);
if !valid_topic(&topic) {
if !topic_valid {
return Err(ClientError::TryRequest(publish));
}
self.request_tx.send_async(publish).await?;
Expand Down Expand Up @@ -508,11 +514,13 @@ impl Client {
S: Into<String>,
P: Into<Bytes>,
{
let topic = topic.into();
let mut publish = Publish::new(&topic, qos, payload, properties);
let topic: String = topic.into();
let topic_valid = valid_topic(&topic);
let topic_bytes = Bytes::from(topic.into_bytes());
let mut publish = Publish::new(topic_bytes, qos, payload, properties);
publish.retain = retain;
let publish = Request::Publish(publish);
if !valid_topic(&topic) {
if !topic_valid {
return Err(ClientError::Request(publish));
}
self.client.request_tx.send(publish)?;
Expand Down
2 changes: 1 addition & 1 deletion rumqttc/src/v5/mqttbytes/v5/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ impl LastWill {
retain: bool,
properties: Option<LastWillProperties>,
) -> LastWill {
let topic = Bytes::copy_from_slice(topic.into().as_bytes());
let topic = Bytes::from(topic.into());
LastWill {
topic,
message: Bytes::from(payload.into()),
Expand Down
4 changes: 2 additions & 2 deletions rumqttc/src/v5/mqttbytes/v5/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ pub struct Publish {
}

impl Publish {
pub fn new<T: Into<String>, P: Into<Bytes>>(
pub fn new<T: Into<Bytes>, P: Into<Bytes>>(
topic: T,
qos: QoS,
payload: P,
properties: Option<PublishProperties>,
) -> Self {
let topic = Bytes::copy_from_slice(topic.into().as_bytes());
let topic = Bytes::from(topic.into());
Self {
qos,
topic,
Expand Down
Loading