Skip to content

Commit

Permalink
Fix Publish and Control error type
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Oct 1, 2023
1 parent 5b29020 commit 9636bf3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changes

## [0.12.3] - 2023-10-01

* Fix Publish and Control error type

## [0.12.2] - 2023-09-25

* Drop unneeded HandshakeError::Server
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ntex-mqtt"
version = "0.12.2"
version = "0.12.3"
authors = ["ntex contributors <team@ntex.rs>"]
description = "Client and Server framework for MQTT v5 and v3.1.1 protocols"
documentation = "https://docs.rs/ntex-mqtt"
Expand Down
10 changes: 3 additions & 7 deletions src/v3/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,16 @@ where
let fut = join(factories.0.create(session.clone()), factories.1.create(session));
let (publish, control) = fut.await;

let publish =
publish.map_err(|e| MqttError::Handshake(HandshakeError::Service(e.into())))?;
let control =
control.map_err(|e| MqttError::Handshake(HandshakeError::Service(e.into())))?;
let publish = publish.map_err(|e| MqttError::Service(e.into()))?;
let control = control.map_err(|e| MqttError::Service(e.into()))?;

let control = BufferService::new(
16,
// limit number of in-flight messages
InFlightService::new(1, control),
)
.map_err(|err| match err {
BufferServiceError::Service(e) => {
MqttError::Handshake(HandshakeError::Service(E::from(e)))
}
BufferServiceError::Service(e) => MqttError::Service(E::from(e)),
BufferServiceError::RequestCanceled => {
MqttError::Handshake(HandshakeError::Disconnected(None))
}
Expand Down
10 changes: 3 additions & 7 deletions src/v5/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,16 @@ where
let (publish, control) =
join(factories.0.create(ses.clone()), factories.1.create(ses)).await;

let publish =
publish.map_err(|e| MqttError::Handshake(HandshakeError::Service(e.into())))?;
let control =
control.map_err(|e| MqttError::Handshake(HandshakeError::Service(e.into())))?;
let publish = publish.map_err(|e| MqttError::Service(e.into()))?;
let control = control.map_err(|e| MqttError::Service(e.into()))?;

let control = BufferService::new(
16,
// limit number of in-flight messages
InFlightService::new(1, control),
)
.map_err(|err| match err {
BufferServiceError::Service(e) => {
MqttError::Handshake(HandshakeError::Service(E::from(e)))
}
BufferServiceError::Service(e) => MqttError::Service(E::from(e)),
BufferServiceError::RequestCanceled => {
MqttError::Handshake(HandshakeError::Disconnected(None))
}
Expand Down

0 comments on commit 9636bf3

Please sign in to comment.