Skip to content

Commit

Permalink
fix(stream): Implement Error for OpenStreamError
Browse files Browse the repository at this point in the history
Pull-Request: libp2p#5169.
  • Loading branch information
dariusc93 authored Feb 29, 2024
1 parent cc29860 commit 60fd566
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ libp2p-relay = { version = "0.17.1", path = "protocols/relay" }
libp2p-rendezvous = { version = "0.14.0", path = "protocols/rendezvous" }
libp2p-request-response = { version = "0.26.2", path = "protocols/request-response" }
libp2p-server = { version = "0.12.6", path = "misc/server" }
libp2p-stream = { version = "0.1.0-alpha", path = "protocols/stream" }
libp2p-stream = { version = "0.1.0-alpha.1", path = "protocols/stream" }
libp2p-swarm = { version = "0.44.2", path = "swarm" }
libp2p-swarm-derive = { version = "=0.34.3", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required.
libp2p-swarm-test = { version = "0.3.0", path = "swarm-test" }
Expand Down
4 changes: 4 additions & 0 deletions protocols/stream/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.0-alpha.1
- Implement Error for `OpenStreamError`.
See [PR 5169](https://github.com/libp2p/rust-libp2p/pull/5169).

## 0.1.0-alpha

Initial release.
2 changes: 1 addition & 1 deletion protocols/stream/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "libp2p-stream"
version = "0.1.0-alpha"
version = "0.1.0-alpha.1"
edition = "2021"
rust-version.workspace = true
description = "Generic stream protocols for libp2p"
Expand Down
9 changes: 9 additions & 0 deletions protocols/stream/src/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ impl fmt::Display for OpenStreamError {
}
}

impl std::error::Error for OpenStreamError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Self::Io(error) => Some(error),
_ => None,
}
}
}

/// A handle to inbound streams for a particular protocol.
#[must_use = "Streams do nothing unless polled."]
pub struct IncomingStreams {
Expand Down

0 comments on commit 60fd566

Please sign in to comment.