Skip to content
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

feat(swarm): add #[non_exhaustive] to key enums #4581

Merged
merged 34 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
207c7ba
adding #[non_exhaustive] to key enums
dhuseby Oct 2, 2023
42a018f
fix swarm/CHANGELOG.md
dhuseby Oct 2, 2023
cd26395
Merge branch 'master' into add-non_exhaustive
dhuseby Oct 2, 2023
9a844b2
fix clippy CI error
dhuseby Oct 2, 2023
c7d8084
Merge branch 'master' into add-non_exhaustive
dhuseby Oct 2, 2023
8edbc27
Update swarm/CHANGELOG.md
dhuseby Oct 3, 2023
f0ecf33
Merge branch 'master' into add-non_exhaustive
dhuseby Oct 3, 2023
1e9561c
Merge branch 'add-non_exhaustive' of github:dhuseby/rust-libp2p into …
dhuseby Oct 3, 2023
2c8ec27
more cleanup
dhuseby Oct 3, 2023
32fbbfa
Merge branch 'master' into add-non_exhaustive
dhuseby Oct 3, 2023
607b6b5
Merge branch 'master' into add-non_exhaustive
dhuseby Oct 3, 2023
36c4ced
Merge branch 'master' into add-non_exhaustive
dhuseby Oct 30, 2023
b87bf96
fixing merge errors
dhuseby Oct 30, 2023
32ba7cd
pinning libp2p-swarm-derive for safety
dhuseby Oct 30, 2023
b8fd915
integrating review changes
dhuseby Oct 31, 2023
1797e27
Merge branch 'master' into add-non_exhaustive
dhuseby Oct 31, 2023
733e617
Update Cargo.toml
dhuseby Oct 31, 2023
eee905f
Merge branch 'master' into add-non_exhaustive
dhuseby Oct 31, 2023
30f1665
Simplify derive code
thomaseizinger Nov 1, 2023
717a577
Fix clippy warnings
thomaseizinger Nov 1, 2023
5e9bf98
Merge branch 'add-non_exhaustive' of github:dhuseby/rust-libp2p into …
dhuseby Nov 1, 2023
c750a58
move swarm-derive comment to the same line in Cargo.toml
dhuseby Nov 1, 2023
789e094
Merge branch 'master' into add-non_exhaustive
dhuseby Nov 1, 2023
344e012
updating CHANGELOGs
dhuseby Nov 1, 2023
21efd9e
fixing kad CHANGELOG
dhuseby Nov 1, 2023
e6aff9f
add libp2p-swarm-derive version pin test
dhuseby Nov 1, 2023
3277209
Revert "updating CHANGELOGs"
thomaseizinger Nov 2, 2023
c85bb0b
Revert "add libp2p-swarm-derive version pin test"
thomaseizinger Nov 2, 2023
3c3e7b5
Extend check to cover pinned version
thomaseizinger Nov 2, 2023
cdd21aa
Merge branch 'master' into add-non_exhaustive
dhuseby Nov 2, 2023
f796df0
update CHANGELOG for swarm-derive
dhuseby Nov 2, 2023
f0c4e0a
Merge branch 'add-non_exhaustive' of github:dhuseby/rust-libp2p into …
dhuseby Nov 2, 2023
e37cbc4
revert swarm-derive/CHANGELOG update
dhuseby Nov 2, 2023
81d7835
Merge branch 'master' into add-non_exhaustive
mergify[bot] Nov 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions misc/allow-block-list/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,19 +233,7 @@ where

fn on_swarm_event(&mut self, event: FromSwarm<Self::ConnectionHandler>) {
match event {
FromSwarm::ConnectionClosed(_) => {}
FromSwarm::ConnectionEstablished(_) => {}
FromSwarm::AddressChange(_) => {}
FromSwarm::DialFailure(_) => {}
FromSwarm::ListenFailure(_) => {}
FromSwarm::NewListener(_) => {}
FromSwarm::NewListenAddr(_) => {}
FromSwarm::ExpiredListenAddr(_) => {}
FromSwarm::ListenerError(_) => {}
FromSwarm::ListenerClosed(_) => {}
FromSwarm::NewExternalAddrCandidate(_) => {}
FromSwarm::ExternalAddrExpired(_) => {}
FromSwarm::ExternalAddrConfirmed(_) => {}
_ => {}
dhuseby marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
10 changes: 1 addition & 9 deletions misc/connection-limits/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,18 +340,10 @@ impl NetworkBehaviour for Behaviour {
FromSwarm::DialFailure(DialFailure { connection_id, .. }) => {
self.pending_outbound_connections.remove(&connection_id);
}
FromSwarm::AddressChange(_) => {}
FromSwarm::ListenFailure(ListenFailure { connection_id, .. }) => {
self.pending_inbound_connections.remove(&connection_id);
}
FromSwarm::NewListener(_) => {}
FromSwarm::NewListenAddr(_) => {}
FromSwarm::ExpiredListenAddr(_) => {}
FromSwarm::ListenerError(_) => {}
FromSwarm::ListenerClosed(_) => {}
FromSwarm::NewExternalAddrCandidate(_) => {}
FromSwarm::ExternalAddrExpired(_) => {}
FromSwarm::ExternalAddrConfirmed(_) => {}
_ => {}
}
}

Expand Down
1 change: 1 addition & 0 deletions misc/metrics/src/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ impl<TBvEv, THandleErr> super::Recorder<libp2p_swarm::SwarmEvent<TBvEv, THandleE
libp2p_swarm::SwarmEvent::Dialing { .. } => {
self.dial_attempt.inc();
}
_ => {}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions protocols/autonat/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ impl NetworkBehaviour for Behaviour {
self.inner.on_swarm_event(listener_closed)
}
confirmed @ FromSwarm::ExternalAddrConfirmed(_) => self.inner.on_swarm_event(confirmed),
_ => {}
}
}

Expand Down
12 changes: 1 addition & 11 deletions protocols/dcutr/src/behaviour_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,17 +365,7 @@ impl NetworkBehaviour for Behaviour {
self.on_connection_closed(connection_closed)
}
FromSwarm::DialFailure(dial_failure) => self.on_dial_failure(dial_failure),
FromSwarm::AddressChange(_)
| FromSwarm::ConnectionEstablished(_)
| FromSwarm::ListenFailure(_)
| FromSwarm::NewListener(_)
| FromSwarm::NewListenAddr(_)
| FromSwarm::ExpiredListenAddr(_)
| FromSwarm::ListenerError(_)
| FromSwarm::ListenerClosed(_)
| FromSwarm::NewExternalAddrCandidate(_)
| FromSwarm::ExternalAddrExpired(_)
| FromSwarm::ExternalAddrConfirmed(_) => {}
_ => {}
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions protocols/dcutr/src/handler/relayed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,7 @@ impl ConnectionHandler for Handler {
ConnectionEvent::DialUpgradeError(dial_upgrade_error) => {
self.on_dial_upgrade_error(dial_upgrade_error)
}
ConnectionEvent::AddressChange(_)
| ConnectionEvent::LocalProtocolsChange(_)
| ConnectionEvent::RemoteProtocolsChange(_) => {}
_ => {}
}
}
}
12 changes: 1 addition & 11 deletions protocols/floodsub/src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,17 +486,7 @@ impl NetworkBehaviour for Floodsub {
FromSwarm::ConnectionClosed(connection_closed) => {
self.on_connection_closed(connection_closed)
}
FromSwarm::AddressChange(_)
| FromSwarm::DialFailure(_)
| FromSwarm::ListenFailure(_)
| FromSwarm::NewListener(_)
| FromSwarm::NewListenAddr(_)
| FromSwarm::ExpiredListenAddr(_)
| FromSwarm::ListenerError(_)
| FromSwarm::ListenerClosed(_)
| FromSwarm::NewExternalAddrCandidate(_)
| FromSwarm::ExternalAddrExpired(_)
| FromSwarm::ExternalAddrConfirmed(_) => {}
_ => {}
}
}
}
Expand Down
11 changes: 1 addition & 10 deletions protocols/gossipsub/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3489,16 +3489,7 @@ where
self.on_connection_closed(connection_closed)
}
FromSwarm::AddressChange(address_change) => self.on_address_change(address_change),
FromSwarm::DialFailure(_)
| FromSwarm::ListenFailure(_)
| FromSwarm::NewListener(_)
| FromSwarm::NewListenAddr(_)
| FromSwarm::ExpiredListenAddr(_)
| FromSwarm::ListenerError(_)
| FromSwarm::ListenerClosed(_)
| FromSwarm::NewExternalAddrCandidate(_)
| FromSwarm::ExternalAddrExpired(_)
| FromSwarm::ExternalAddrConfirmed(_) => {}
_ => {}
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions protocols/gossipsub/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,10 +553,7 @@ impl ConnectionHandler for Handler {
}) => {
log::debug!("Protocol negotiation failed: {e}")
}
ConnectionEvent::AddressChange(_)
| ConnectionEvent::ListenUpgradeError(_)
| ConnectionEvent::LocalProtocolsChange(_)
| ConnectionEvent::RemoteProtocolsChange(_) => {}
_ => {}
}
}
Handler::Disabled(_) => {}
Expand Down
11 changes: 1 addition & 10 deletions protocols/identify/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,16 +395,7 @@ impl NetworkBehaviour for Behaviour {
}
}
}
FromSwarm::NewListenAddr(_)
| FromSwarm::ExpiredListenAddr(_)
| FromSwarm::AddressChange(_)
| FromSwarm::ListenFailure(_)
| FromSwarm::NewListener(_)
| FromSwarm::ListenerError(_)
| FromSwarm::ListenerClosed(_)
| FromSwarm::NewExternalAddrCandidate(_)
| FromSwarm::ExternalAddrExpired(_) => {}
FromSwarm::ExternalAddrConfirmed(_) => {}
_ => {}
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions protocols/identify/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,6 @@ impl ConnectionHandler for Handler {
));
self.trigger_next_identify.reset(self.interval);
}
ConnectionEvent::AddressChange(_)
| ConnectionEvent::ListenUpgradeError(_)
| ConnectionEvent::RemoteProtocolsChange(_) => {}
ConnectionEvent::LocalProtocolsChange(change) => {
let before = log::log_enabled!(Level::Debug)
.then(|| self.local_protocols_to_string())
Expand All @@ -439,6 +436,7 @@ impl ConnectionHandler for Handler {
});
}
}
_ => {}
}
}
}
Expand Down
10 changes: 1 addition & 9 deletions protocols/kad/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2543,15 +2543,7 @@ where
}
FromSwarm::DialFailure(dial_failure) => self.on_dial_failure(dial_failure),
FromSwarm::AddressChange(address_change) => self.on_address_change(address_change),
FromSwarm::ExpiredListenAddr(_)
| FromSwarm::NewExternalAddrCandidate(_)
| FromSwarm::NewListenAddr(_)
| FromSwarm::ListenFailure(_)
| FromSwarm::NewListener(_)
| FromSwarm::ListenerClosed(_)
| FromSwarm::ListenerError(_)
| FromSwarm::ExternalAddrExpired(_)
| FromSwarm::ExternalAddrConfirmed(_) => {}
_ => {}
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions protocols/kad/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,9 +792,6 @@ impl ConnectionHandler for Handler {
ConnectionEvent::DialUpgradeError(dial_upgrade_error) => {
self.on_dial_upgrade_error(dial_upgrade_error)
}
ConnectionEvent::AddressChange(_)
| ConnectionEvent::ListenUpgradeError(_)
| ConnectionEvent::LocalProtocolsChange(_) => {}
ConnectionEvent::RemoteProtocolsChange(change) => {
let dirty = self.remote_supported_protocols.on_protocols_change(change);

Expand Down Expand Up @@ -828,6 +825,7 @@ impl ConnectionHandler for Handler {
}
}
}
_ => {}
}
}
}
Expand Down
13 changes: 1 addition & 12 deletions protocols/mdns/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,18 +234,7 @@ where
iface.fire_timer();
}
}
FromSwarm::ConnectionClosed(_)
| FromSwarm::ConnectionEstablished(_)
| FromSwarm::DialFailure(_)
| FromSwarm::AddressChange(_)
| FromSwarm::ListenFailure(_)
| FromSwarm::NewListenAddr(_)
| FromSwarm::ExpiredListenAddr(_)
| FromSwarm::ListenerError(_)
| FromSwarm::ListenerClosed(_)
| FromSwarm::NewExternalAddrCandidate(_)
| FromSwarm::ExternalAddrExpired(_)
| FromSwarm::ExternalAddrConfirmed(_) => {}
_ => {}
}
}

Expand Down
12 changes: 1 addition & 11 deletions protocols/perf/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,7 @@ impl NetworkBehaviour for Behaviour {
assert!(self.connected.remove(&peer_id));
}
}
FromSwarm::AddressChange(_)
| FromSwarm::DialFailure(_)
| FromSwarm::ListenFailure(_)
| FromSwarm::NewListener(_)
| FromSwarm::NewListenAddr(_)
| FromSwarm::ExpiredListenAddr(_)
| FromSwarm::ListenerError(_)
| FromSwarm::ListenerClosed(_)
| FromSwarm::NewExternalAddrCandidate(_)
| FromSwarm::ExternalAddrConfirmed(_)
| FromSwarm::ExternalAddrExpired(_) => {}
_ => {}
};

self.request_response.on_swarm_event(event);
Expand Down
5 changes: 1 addition & 4 deletions protocols/ping/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,7 @@ impl ConnectionHandler for Handler {
ConnectionEvent::DialUpgradeError(dial_upgrade_error) => {
self.on_dial_upgrade_error(dial_upgrade_error)
}
ConnectionEvent::AddressChange(_)
| ConnectionEvent::ListenUpgradeError(_)
| ConnectionEvent::LocalProtocolsChange(_)
| ConnectionEvent::RemoteProtocolsChange(_) => {}
_ => {}
}
}
}
Expand Down
14 changes: 1 addition & 13 deletions protocols/ping/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,20 +154,8 @@
}

fn on_swarm_event(&mut self, event: FromSwarm<Self::ConnectionHandler>) {
match event {

Check failure on line 157 in protocols/ping/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy (1.72.0)

this match could be replaced by its body itself

Check failure on line 157 in protocols/ping/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy (beta)

this match could be replaced by its body itself
FromSwarm::ConnectionEstablished(_)
| FromSwarm::ConnectionClosed(_)
| FromSwarm::AddressChange(_)
| FromSwarm::DialFailure(_)
| FromSwarm::ListenFailure(_)
| FromSwarm::NewListener(_)
| FromSwarm::NewListenAddr(_)
| FromSwarm::ExpiredListenAddr(_)
| FromSwarm::ListenerError(_)
| FromSwarm::ListenerClosed(_)
| FromSwarm::NewExternalAddrCandidate(_)
| FromSwarm::ExternalAddrExpired(_)
| FromSwarm::ExternalAddrConfirmed(_) => {}
_ => {}
}
}
}
13 changes: 1 addition & 12 deletions protocols/relay/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,18 +339,7 @@ impl NetworkBehaviour for Behaviour {
FromSwarm::ConnectionClosed(connection_closed) => {
self.on_connection_closed(connection_closed)
}
FromSwarm::ConnectionEstablished(_)
| FromSwarm::DialFailure(_)
| FromSwarm::AddressChange(_)
| FromSwarm::ListenFailure(_)
| FromSwarm::NewListener(_)
| FromSwarm::NewListenAddr(_)
| FromSwarm::ExpiredListenAddr(_)
| FromSwarm::ListenerError(_)
| FromSwarm::ListenerClosed(_)
| FromSwarm::NewExternalAddrCandidate(_)
| FromSwarm::ExternalAddrExpired(_)
| FromSwarm::ExternalAddrConfirmed(_) => {}
_ => {}
}
}

Expand Down
5 changes: 1 addition & 4 deletions protocols/relay/src/behaviour/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -922,10 +922,7 @@ impl ConnectionHandler for Handler {
ConnectionEvent::DialUpgradeError(dial_upgrade_error) => {
self.on_dial_upgrade_error(dial_upgrade_error);
}
ConnectionEvent::AddressChange(_)
| ConnectionEvent::ListenUpgradeError(_)
| ConnectionEvent::LocalProtocolsChange(_)
| ConnectionEvent::RemoteProtocolsChange(_) => {}
_ => {}
}
}
}
Expand Down
11 changes: 1 addition & 10 deletions protocols/relay/src/priv_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,7 @@ impl NetworkBehaviour for Behaviour {
FromSwarm::DialFailure(DialFailure { connection_id, .. }) => {
self.pending_handler_commands.remove(&connection_id);
}
FromSwarm::AddressChange(_)
| FromSwarm::ListenFailure(_)
| FromSwarm::NewListener(_)
| FromSwarm::NewListenAddr(_)
| FromSwarm::ExpiredListenAddr(_)
| FromSwarm::ListenerError(_)
| FromSwarm::ListenerClosed(_)
| FromSwarm::NewExternalAddrCandidate(_)
| FromSwarm::ExternalAddrExpired(_)
| FromSwarm::ExternalAddrConfirmed(_) => {}
_ => {}
}
}

Expand Down
4 changes: 1 addition & 3 deletions protocols/relay/src/priv_client/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,9 +577,7 @@ impl ConnectionHandler for Handler {
ConnectionEvent::DialUpgradeError(dial_upgrade_error) => {
self.on_dial_upgrade_error(dial_upgrade_error)
}
ConnectionEvent::AddressChange(_)
| ConnectionEvent::LocalProtocolsChange(_)
| ConnectionEvent::RemoteProtocolsChange(_) => {}
_ => {}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions protocols/rendezvous/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ impl NetworkBehaviour for Behaviour {

return Poll::Ready(new_to_swarm);
}
Poll::Ready(_) => {}
Poll::Pending => {}
thomaseizinger marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down
1 change: 1 addition & 0 deletions protocols/rendezvous/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ impl NetworkBehaviour for Behaviour {

return Poll::Ready(new_to_swarm);
}
_ => {}
thomaseizinger marked this conversation as resolved.
Show resolved Hide resolved
};
}

Expand Down
4 changes: 1 addition & 3 deletions protocols/request-response/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,7 @@ where
ConnectionEvent::ListenUpgradeError(listen_upgrade_error) => {
self.on_listen_upgrade_error(listen_upgrade_error)
}
ConnectionEvent::AddressChange(_)
| ConnectionEvent::LocalProtocolsChange(_)
| ConnectionEvent::RemoteProtocolsChange(_) => {}
_ => {}
}
}
}
10 changes: 1 addition & 9 deletions protocols/request-response/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,15 +775,7 @@ where
}
FromSwarm::AddressChange(address_change) => self.on_address_change(address_change),
FromSwarm::DialFailure(dial_failure) => self.on_dial_failure(dial_failure),
FromSwarm::ListenFailure(_) => {}
FromSwarm::NewListener(_) => {}
FromSwarm::NewListenAddr(_) => {}
FromSwarm::ExpiredListenAddr(_) => {}
FromSwarm::ListenerError(_) => {}
FromSwarm::ListenerClosed(_) => {}
FromSwarm::NewExternalAddrCandidate(_) => {}
FromSwarm::ExternalAddrExpired(_) => {}
FromSwarm::ExternalAddrConfirmed(_) => {}
_ => {}
}
}

Expand Down
Loading
Loading