diff --git a/Cargo.lock b/Cargo.lock index 851bfb00..b6063da2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2878,7 +2878,7 @@ dependencies = [ [[package]] name = "libp2p-request-response" -version = "0.24.0" +version = "0.24.1" dependencies = [ "async-std", "async-trait", diff --git a/protocols/request-response/CHANGELOG.md b/protocols/request-response/CHANGELOG.md index e31581f6..ac237dbd 100644 --- a/protocols/request-response/CHANGELOG.md +++ b/protocols/request-response/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.24.1 - unreleased + +- Deprecate `handler`, `codec` modules to make them private. See [PR 3847]. + +[PR 3847]: https://github.com/libp2p/rust-libp2p/pull/3847 + ## 0.24.0 - Update to `libp2p-core` `v0.39.0`. diff --git a/protocols/request-response/Cargo.toml b/protocols/request-response/Cargo.toml index b6ece95c..75cbdc36 100644 --- a/protocols/request-response/Cargo.toml +++ b/protocols/request-response/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-request-response" edition = "2021" rust-version = "1.62.0" description = "Generic Request/Response Protocols" -version = "0.24.0" +version = "0.24.1" authors = ["Parity Technologies "] license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/protocols/request-response/src/codec.rs b/protocols/request-response/src/codec_priv.rs similarity index 100% rename from protocols/request-response/src/codec.rs rename to protocols/request-response/src/codec_priv.rs diff --git a/protocols/request-response/src/handler.rs b/protocols/request-response/src/handler_priv.rs similarity index 99% rename from protocols/request-response/src/handler.rs rename to protocols/request-response/src/handler_priv.rs index 50cd6adb..849c9e57 100644 --- a/protocols/request-response/src/handler.rs +++ b/protocols/request-response/src/handler_priv.rs @@ -20,7 +20,7 @@ mod protocol; -use crate::codec::Codec; +use crate::codec_priv::Codec; use crate::{RequestId, EMPTY_QUEUE_SHRINK_THRESHOLD}; use libp2p_swarm::handler::{ diff --git a/protocols/request-response/src/handler/protocol.rs b/protocols/request-response/src/handler_priv/protocol.rs similarity index 99% rename from protocols/request-response/src/handler/protocol.rs rename to protocols/request-response/src/handler_priv/protocol.rs index 84ef3657..3ee08c7f 100644 --- a/protocols/request-response/src/handler/protocol.rs +++ b/protocols/request-response/src/handler_priv/protocol.rs @@ -23,7 +23,7 @@ //! receives a request and sends a response, whereas the //! outbound upgrade send a request and receives a response. -use crate::codec::Codec; +use crate::codec_priv::Codec; use crate::RequestId; use futures::{channel::oneshot, future::BoxFuture, prelude::*}; diff --git a/protocols/request-response/src/lib.rs b/protocols/request-response/src/lib.rs index d9f2220d..723c11d8 100644 --- a/protocols/request-response/src/lib.rs +++ b/protocols/request-response/src/lib.rs @@ -58,18 +58,31 @@ #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] -pub mod codec; -pub mod handler; +mod codec_priv; +#[deprecated( + note = "The `codec` module will be made private in the future and should not be depended on." +)] +pub mod codec { + pub use super::codec_priv::*; +} -pub use codec::{Codec, ProtocolName}; +mod handler_priv; +#[deprecated( + note = "The `handler` module will be made private in the future and should not be depended on." +)] +pub mod handler { + pub use super::handler_priv::*; +} + +pub use codec_priv::{Codec, ProtocolName}; #[allow(deprecated)] -pub use codec::RequestResponseCodec; +pub use codec_priv::RequestResponseCodec; -pub use handler::ProtocolSupport; +pub use handler_priv::ProtocolSupport; use futures::channel::oneshot; -use handler::{Handler, RequestProtocol}; +use handler_priv::{Handler, RequestProtocol}; use libp2p_core::{ConnectedPoint, Endpoint, Multiaddr}; use libp2p_identity::PeerId; use libp2p_swarm::{ @@ -116,7 +129,7 @@ pub type RequestResponseMessage = since = "0.24.0", note = "Use re-exports that omit `RequestResponse` prefix, i.e. `libp2p::request_response::handler::Event`" )] -pub type HandlerEvent = handler::Event; +pub type HandlerEvent = handler_priv::Event; /// An inbound request or response. #[derive(Debug)] @@ -802,7 +815,7 @@ where event: THandlerOutEvent, ) { match event { - handler::Event::Response { + handler_priv::Event::Response { request_id, response, } => { @@ -819,7 +832,7 @@ where self.pending_events .push_back(ToSwarm::GenerateEvent(Event::Message { peer, message })); } - handler::Event::Request { + handler_priv::Event::Request { request_id, request, sender, @@ -850,7 +863,7 @@ where } } } - handler::Event::ResponseSent(request_id) => { + handler_priv::Event::ResponseSent(request_id) => { let removed = self.remove_pending_outbound_response(&peer, connection, request_id); debug_assert!( removed, @@ -863,7 +876,7 @@ where request_id, })); } - handler::Event::ResponseOmission(request_id) => { + handler_priv::Event::ResponseOmission(request_id) => { let removed = self.remove_pending_outbound_response(&peer, connection, request_id); debug_assert!( removed, @@ -877,7 +890,7 @@ where error: InboundFailure::ResponseOmission, })); } - handler::Event::OutboundTimeout(request_id) => { + handler_priv::Event::OutboundTimeout(request_id) => { let removed = self.remove_pending_inbound_response(&peer, connection, &request_id); debug_assert!( removed, @@ -891,7 +904,7 @@ where error: OutboundFailure::Timeout, })); } - handler::Event::InboundTimeout(request_id) => { + handler_priv::Event::InboundTimeout(request_id) => { // Note: `Event::InboundTimeout` is emitted both for timing // out to receive the request and for timing out sending the response. In the former // case the request is never added to `pending_outbound_responses` and thus one can @@ -905,7 +918,7 @@ where error: InboundFailure::Timeout, })); } - handler::Event::OutboundUnsupportedProtocols(request_id) => { + handler_priv::Event::OutboundUnsupportedProtocols(request_id) => { let removed = self.remove_pending_inbound_response(&peer, connection, &request_id); debug_assert!( removed, @@ -919,7 +932,7 @@ where error: OutboundFailure::UnsupportedProtocols, })); } - handler::Event::InboundUnsupportedProtocols(request_id) => { + handler_priv::Event::InboundUnsupportedProtocols(request_id) => { // Note: No need to call `self.remove_pending_outbound_response`, // `Event::Request` was never emitted for this request and // thus request was never added to `pending_outbound_responses`.