Skip to content

Commit 87f58c3

Browse files
committed
revert Box<dyn Error> to String conversion.
1 parent 3f3f745 commit 87f58c3

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

protocols/upnp/src/gateway.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,14 @@ pub trait Gateway: Sized + Send + Sync {
6464
protocol: Protocol,
6565
addr: SocketAddrV4,
6666
duration: Duration,
67-
) -> Result<(), String>;
67+
) -> Result<(), Box<dyn Error + Send + Sync + 'static>>;
6868

6969
/// Remove port mapping on the gateway.
70-
async fn remove_port(_: Arc<Self>, protocol: Protocol, port: u16) -> Result<(), String>;
70+
async fn remove_port(
71+
_: Arc<Self>,
72+
protocol: Protocol,
73+
port: u16,
74+
) -> Result<(), Box<dyn Error + Send + Sync + 'static>>;
7175

7276
// /// Spawn a future on the executor.
7377
fn spawn<F>(f: F)

protocols/upnp/src/gateway/async_std.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl super::Gateway for Gateway {
5353
protocol: Protocol,
5454
addr: SocketAddrV4,
5555
duration: Duration,
56-
) -> Result<(), String> {
56+
) -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
5757
let protocol = match protocol {
5858
Protocol::Tcp => PortMappingProtocol::TCP,
5959
Protocol::Udp => PortMappingProtocol::UDP,
@@ -67,18 +67,22 @@ impl super::Gateway for Gateway {
6767
"rust-libp2p mapping",
6868
)
6969
.await
70-
.map_err(|err| err.to_string())
70+
.map_err(|err| err.into())
7171
}
7272

73-
async fn remove_port(gateway: Arc<Self>, protocol: Protocol, port: u16) -> Result<(), String> {
73+
async fn remove_port(
74+
gateway: Arc<Self>,
75+
protocol: Protocol,
76+
port: u16,
77+
) -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
7478
let protocol = match protocol {
7579
Protocol::Tcp => PortMappingProtocol::TCP,
7680
Protocol::Udp => PortMappingProtocol::UDP,
7781
};
7882
gateway
7983
.remove_port(protocol, port)
8084
.await
81-
.map_err(|err| err.to_string())
85+
.map_err(|err| err.into())
8286
}
8387
fn spawn<F>(f: F)
8488
where

protocols/upnp/src/gateway/tokio.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl super::Gateway for Gateway {
5353
protocol: Protocol,
5454
addr: SocketAddrV4,
5555
duration: Duration,
56-
) -> Result<(), String> {
56+
) -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
5757
let protocol = match protocol {
5858
Protocol::Tcp => PortMappingProtocol::TCP,
5959
Protocol::Udp => PortMappingProtocol::UDP,
@@ -67,18 +67,22 @@ impl super::Gateway for Gateway {
6767
"rust-libp2p mapping",
6868
)
6969
.await
70-
.map_err(|err| err.to_string())
70+
.map_err(|err| err.into())
7171
}
7272

73-
async fn remove_port(gateway: Arc<Self>, protocol: Protocol, port: u16) -> Result<(), String> {
73+
async fn remove_port(
74+
gateway: Arc<Self>,
75+
protocol: Protocol,
76+
port: u16,
77+
) -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
7478
let protocol = match protocol {
7579
Protocol::Tcp => PortMappingProtocol::TCP,
7680
Protocol::Udp => PortMappingProtocol::UDP,
7781
};
7882
gateway
7983
.remove_port(protocol, port)
8084
.await
81-
.map_err(|err| err.to_string())
85+
.map_err(|err| err.into())
8286
}
8387

8488
fn spawn<F>(f: F)

0 commit comments

Comments
 (0)