Skip to content

Commit 3118503

Browse files
chore(swarm): remove deprecated symbols
Pull-Request: #4737.
1 parent 20e4b36 commit 3118503

File tree

12 files changed

+16
-328
lines changed

12 files changed

+16
-328
lines changed

Cargo.lock

Lines changed: 0 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libp2p/src/tutorials/ping.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
//! to the [`Transport`] as well as events from the [`Transport`] to the [`NetworkBehaviour`].
166166
//!
167167
//! ```rust
168-
//! use libp2p::swarm::{NetworkBehaviour, SwarmBuilder};
168+
//! use libp2p::swarm::NetworkBehaviour;
169169
//! use libp2p::{identity, ping, PeerId};
170170
//! use std::error::Error;
171171
//!
@@ -198,7 +198,7 @@
198198
//! Thus, without any other behaviour in place, we would not be able to observe the pings.
199199
//!
200200
//! ```rust
201-
//! use libp2p::swarm::{NetworkBehaviour, SwarmBuilder};
201+
//! use libp2p::swarm::NetworkBehaviour;
202202
//! use libp2p::{identity, ping, PeerId};
203203
//! use std::error::Error;
204204
//! use std::time::Duration;
@@ -249,7 +249,6 @@
249249
//! remote peer.
250250
//!
251251
//! ```rust
252-
//! use libp2p::swarm::{NetworkBehaviour, SwarmBuilder};
253252
//! use libp2p::{identity, ping, Multiaddr, PeerId};
254253
//! use std::error::Error;
255254
//! use std::time::Duration;
@@ -291,7 +290,7 @@
291290
//!
292291
//! ```no_run
293292
//! use futures::prelude::*;
294-
//! use libp2p::swarm::{NetworkBehaviour, SwarmEvent, SwarmBuilder};
293+
//! use libp2p::swarm::{NetworkBehaviour, SwarmEvent};
295294
//! use libp2p::{identity, ping, Multiaddr, PeerId};
296295
//! use std::error::Error;
297296
//! use std::time::Duration;

protocols/gossipsub/src/lib.rs

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -89,53 +89,7 @@
8989
9090
//! ## Example
9191
//!
92-
//! An example of initialising a gossipsub compatible swarm:
93-
//!
94-
//! ```
95-
//! # use libp2p_gossipsub::Event;
96-
//! # use libp2p_core::{transport::{Transport, MemoryTransport}, Multiaddr};
97-
//! # use libp2p_gossipsub::MessageAuthenticity;
98-
//! # use libp2p_identity as identity;
99-
//! let local_key = identity::Keypair::generate_ed25519();
100-
//! let local_peer_id = local_key.public().to_peer_id();
101-
//!
102-
//! // Set up an encrypted TCP Transport over yamux
103-
//! // This is test transport (memory).
104-
//! let transport = MemoryTransport::default()
105-
//! .upgrade(libp2p_core::upgrade::Version::V1)
106-
//! .authenticate(libp2p_noise::Config::new(&local_key).unwrap())
107-
//! .multiplex(libp2p_yamux::Config::default())
108-
//! .boxed();
109-
//!
110-
//! // Create a Gossipsub topic
111-
//! let topic = libp2p_gossipsub::IdentTopic::new("example");
112-
//!
113-
//! // Set the message authenticity - How we expect to publish messages
114-
//! // Here we expect the publisher to sign the message with their key.
115-
//! let message_authenticity = MessageAuthenticity::Signed(local_key);
116-
//!
117-
//! // Create a Swarm to manage peers and events
118-
//! let mut swarm = {
119-
//! // set default parameters for gossipsub
120-
//! let gossipsub_config = libp2p_gossipsub::Config::default();
121-
//! // build a gossipsub network behaviour
122-
//! let mut gossipsub: libp2p_gossipsub::Behaviour =
123-
//! libp2p_gossipsub::Behaviour::new(message_authenticity, gossipsub_config).unwrap();
124-
//! // subscribe to the topic
125-
//! gossipsub.subscribe(&topic);
126-
//! // create the swarm (use an executor in a real example)
127-
//! libp2p_swarm::SwarmBuilder::without_executor(
128-
//! transport,
129-
//! gossipsub,
130-
//! local_peer_id,
131-
//! ).build()
132-
//! };
133-
//!
134-
//! // Listen on a memory transport.
135-
//! let memory: Multiaddr = libp2p_core::multiaddr::Protocol::Memory(10).into();
136-
//! let addr = swarm.listen_on(memory).unwrap();
137-
//! println!("Listening on {:?}", addr);
138-
//! ```
92+
//! For an example on how to use gossipsub, see the [chat-example](https://github.com/libp2p/rust-libp2p/tree/master/examples/chat).
13993
14094
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
14195

protocols/request-response/src/cbor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
///
2626
/// ```
2727
/// # use libp2p_request_response::{cbor, ProtocolSupport, self as request_response};
28-
/// # use libp2p_swarm::{StreamProtocol, SwarmBuilder};
28+
/// # use libp2p_swarm::StreamProtocol;
2929
/// #[derive(Debug, serde::Serialize, serde::Deserialize)]
3030
/// struct GreetRequest {
3131
/// name: String,

swarm-derive/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
- Adapt to interface changes in `libp2p-swarm`.
44
See [PR 4706](https://github.com/libp2p/rust-libp2p/pull/4076).
5+
- Remove supported for deprecated `#[behaviour(out_event = "...")]`.
6+
To same functionality is available using `#[behaviour(to_swarm = "...")]`
7+
See [PR 4737](https://github.com/libp2p/rust-libp2p/pull/4737).
58

69
## 0.33.0
710

swarm-derive/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ proc-macro = true
1717
heck = "0.4"
1818
quote = "1.0"
1919
syn = { version = "2.0.38", default-features = false, features = ["clone-impls", "derive", "parsing", "printing", "proc-macro"] }
20-
proc-macro-warning = "1.0.0"
2120
proc-macro2 = "1.0"
2221

2322
# Passing arguments to the docsrs builder in order to properly document cfg's.

swarm-derive/src/lib.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use heck::ToUpperCamelCase;
2828
use proc_macro::TokenStream;
2929
use quote::quote;
3030
use syn::punctuated::Punctuated;
31-
use syn::spanned::Spanned;
3231
use syn::{parse_macro_input, Data, DataStruct, DeriveInput, Meta, Token};
3332

3433
/// Generates a delegating `NetworkBehaviour` implementation for the struct this is used for. See
@@ -61,7 +60,6 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> syn::Result<Toke
6160
let BehaviourAttributes {
6261
prelude_path,
6362
user_specified_out_event,
64-
deprecation_tokenstream,
6563
} = parse_attributes(ast)?;
6664

6765
let multiaddr = quote! { #prelude_path::Multiaddr };
@@ -756,8 +754,6 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> syn::Result<Toke
756754

757755
// Now the magic happens.
758756
let final_quote = quote! {
759-
#deprecation_tokenstream
760-
761757
#out_event_definition
762758

763759
impl #impl_generics #trait_to_impl for #name #ty_generics
@@ -881,15 +877,13 @@ fn build_struct(ast: &DeriveInput, data_struct: &DataStruct) -> syn::Result<Toke
881877
struct BehaviourAttributes {
882878
prelude_path: syn::Path,
883879
user_specified_out_event: Option<syn::Type>,
884-
deprecation_tokenstream: proc_macro2::TokenStream,
885880
}
886881

887882
/// Parses the `value` of a key=value pair in the `#[behaviour]` attribute into the requested type.
888883
fn parse_attributes(ast: &DeriveInput) -> syn::Result<BehaviourAttributes> {
889884
let mut attributes = BehaviourAttributes {
890885
prelude_path: syn::parse_quote! { ::libp2p::swarm::derive_prelude },
891886
user_specified_out_event: None,
892-
deprecation_tokenstream: proc_macro2::TokenStream::new(),
893887
};
894888

895889
for attr in ast
@@ -909,16 +903,6 @@ fn parse_attributes(ast: &DeriveInput) -> syn::Result<BehaviourAttributes> {
909903
}
910904

911905
if meta.path().is_ident("to_swarm") || meta.path().is_ident("out_event") {
912-
if meta.path().is_ident("out_event") {
913-
let warning = proc_macro_warning::FormattedWarning::new_deprecated(
914-
"out_event_renamed_to_to_swarm",
915-
"The `out_event` attribute has been renamed to `to_swarm`.",
916-
meta.span(),
917-
);
918-
919-
attributes.deprecation_tokenstream = quote::quote! { #warning };
920-
}
921-
922906
let value = meta.require_name_value()?.value.require_str_lit()?;
923907

924908
attributes.user_specified_out_event = Some(syn::parse_str(&value)?);

swarm/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
See [PR 4715](https://github.com/libp2p/rust-libp2p/pull/4715).
1717
- Log `PeerId` of `Swarm` even when constructed with new `SwarmBuilder`.
1818
See [PR 4671](https://github.com/libp2p/rust-libp2p/pull/4671).
19+
- Remove deprecated symbols.
20+
See [PR 4737](https://github.com/libp2p/rust-libp2p/pull/4737).
1921

2022
## 0.43.6
2123

swarm/src/handler.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -668,9 +668,6 @@ impl<TConnectionUpgrade, TOutboundOpenInfo, TCustom, TErr>
668668
}
669669
}
670670

671-
#[deprecated(note = "Renamed to `StreamUpgradeError`")]
672-
pub type ConnectionHandlerUpgrErr<TUpgrErr> = StreamUpgradeError<TUpgrErr>;
673-
674671
/// Error that can happen on an outbound substream opening attempt.
675672
#[derive(Debug)]
676673
pub enum StreamUpgradeError<TUpgrErr> {

0 commit comments

Comments
 (0)