Skip to content

Commit

Permalink
feat(core): deprecate OptionalUpgrade
Browse files Browse the repository at this point in the history
This is dead-code, we don't use it in our codebase. I am suggesting to remove it because it creates an unnecessary API surface.

Related: #3747.
Related: #3271.

Pull-Request: #3806.
thomaseizinger authored Apr 26, 2023

Verified

This commit was signed with the committer’s verified signature.
pompon0 Grzegorz Prusak
1 parent 9681116 commit e5dbeb3
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -7,8 +7,12 @@
- Deprecate `{In,Out}boundUpgradeExt`, as they are not used in rust-libp2p.
See [PR 3807].

- Deprecate `OptionalUpgrade` without replacement.
See [PR 3806].

[PR 3747]: https://github.com/libp2p/rust-libp2p/pull/3747
[PR 3807]: https://github.com/libp2p/rust-libp2p/pull/3807
[PR 3806]: https://github.com/libp2p/rust-libp2p/pull/3806

## 0.39.1

6 changes: 3 additions & 3 deletions core/src/upgrade.rs
Original file line number Diff line number Diff line change
@@ -77,17 +77,17 @@ pub use self::{
apply::{apply, apply_inbound, apply_outbound, InboundUpgradeApply, OutboundUpgradeApply},
denied::DeniedUpgrade,
error::UpgradeError,
optional::OptionalUpgrade,
pending::PendingUpgrade,
ready::ReadyUpgrade,
select::SelectUpgrade,
transfer::{read_length_prefixed, read_varint, write_length_prefixed, write_varint},
};
pub use crate::Negotiated;
pub use multistream_select::{NegotiatedComplete, NegotiationError, ProtocolError, Version};

#[allow(deprecated)]
pub use map::{MapInboundUpgrade, MapInboundUpgradeErr, MapOutboundUpgrade, MapOutboundUpgradeErr};
pub use multistream_select::{NegotiatedComplete, NegotiationError, ProtocolError, Version};
#[allow(deprecated)]
pub use optional::OptionalUpgrade;

/// Types serving as protocol names.
///
5 changes: 5 additions & 0 deletions core/src/upgrade/optional.rs
Original file line number Diff line number Diff line change
@@ -18,13 +18,18 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

#![allow(deprecated)]

use crate::upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo};

/// Upgrade that can be disabled at runtime.
///
/// Wraps around an `Option<T>` and makes it available or not depending on whether it contains or
/// not an upgrade.
#[derive(Debug, Clone)]
#[deprecated(
note = "Will be removed without replacement because it is not used within rust-libp2p."
)]
pub struct OptionalUpgrade<T>(Option<T>);

impl<T> OptionalUpgrade<T> {

0 comments on commit e5dbeb3

Please sign in to comment.