-
Notifications
You must be signed in to change notification settings - Fork 949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core/either: Remove EitherName
in favor of Either
#2798
Closed
Closed
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
74f3e10
core/either: Remove `EitherName` in favor of `Either`
thomaseizinger 28bbbf4
Update core/CHANGELOG.md
thomaseizinger 1d86e3c
Format code
thomaseizinger 21205fd
Transition `UpgradeInfo::Info` to &'static [u8] where feasible
thomaseizinger 8016a0e
Replace blanket `ProtocolName` impl with specific ones
thomaseizinger 31956ac
Add changelog entry for `ProtocolName` change
thomaseizinger 8db6355
Merge branch 'master' into replace-either-name-with-either
thomaseizinger 7d646d7
Transition from `String` to `&'static [u8]'` for PendingConnectionHan…
thomaseizinger 7e76ab1
Don't use `&str` for `ProtocolName` in docs
thomaseizinger e116f05
Appease clippy
thomaseizinger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,16 @@ | |
- Change `StreamMuxer` interface to be entirely poll-based. All functions on `StreamMuxer` now | ||
require a `Context` and return `Poll`. This gives callers fine-grained control over what they | ||
would like to make progress on. See [PR 2724] and [PR 2797]. | ||
- Remove `EitherName` in favor of `Either` from the `either` crate. See [PR 2798]. | ||
- Replace blanket `ProtocolName` impl with specific ones on `&'static [u8]` and `Cow<'static, [u8]>`. See [PR 2798]. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not implement |
||
|
||
[PR 2724]: https://github.com/libp2p/rust-libp2p/pull/2724 | ||
[PR 2762]: https://github.com/libp2p/rust-libp2p/pull/2762 | ||
[PR 2775]: https://github.com/libp2p/rust-libp2p/pull/2775 | ||
[PR 2776]: https://github.com/libp2p/rust-libp2p/pull/2776 | ||
[PR 2765]: https://github.com/libp2p/rust-libp2p/pull/2765 | ||
[PR 2797]: https://github.com/libp2p/rust-libp2p/pull/2797 | ||
[PR 2798]: https://github.com/libp2p/rust-libp2p/pull/2798 | ||
|
||
# 0.34.0 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,7 +68,9 @@ mod pending; | |
mod select; | ||
mod transfer; | ||
|
||
use ::either::Either; | ||
use futures::future::Future; | ||
use std::borrow::Cow; | ||
|
||
pub use self::{ | ||
apply::{apply, apply_inbound, apply_outbound, InboundUpgradeApply, OutboundUpgradeApply}, | ||
|
@@ -126,12 +128,28 @@ pub trait ProtocolName { | |
fn protocol_name(&self) -> &[u8]; | ||
} | ||
|
||
impl<T: AsRef<[u8]>> ProtocolName for T { | ||
impl ProtocolName for &'static [u8] { | ||
fn protocol_name(&self) -> &[u8] { | ||
self | ||
} | ||
} | ||
|
||
impl ProtocolName for Cow<'static, [u8]> { | ||
fn protocol_name(&self) -> &[u8] { | ||
self.as_ref() | ||
} | ||
} | ||
|
||
impl<A, B> ProtocolName for Either<A, B> | ||
where | ||
A: ProtocolName, | ||
B: ProtocolName, | ||
{ | ||
fn protocol_name(&self) -> &[u8] { | ||
::either::for_both!(self, inner => inner.protocol_name()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Neat! |
||
} | ||
} | ||
|
||
/// Common trait for upgrades that can be applied on inbound substreams, outbound substreams, | ||
/// or both. | ||
pub trait UpgradeInfo { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could split this out into a different PR if you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am fine with a single pull request only.