Skip to content

Commit d357445

Browse files
rename
1 parent c5ef01f commit d357445

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ futures-buffered = "0.2.4"
6060
hyper-transport = ["dep:flume", "dep:hyper", "dep:bincode", "dep:bytes", "dep:tokio-serde", "dep:tokio-util"]
6161
quinn-transport = ["dep:flume", "dep:quinn", "dep:bincode", "dep:tokio-serde", "dep:tokio-util"]
6262
flume-transport = ["dep:flume"]
63-
async-channel-transport = ["dep:tokio-util", "dep:tokio-stream"]
63+
tokio-mpsc-transport = ["dep:tokio-util", "dep:tokio-stream"]
6464
interprocess-transport = ["quinn-transport", "quinn-flume-socket", "dep:quinn-udp", "dep:interprocess", "dep:bytes", "dep:tokio-util", "dep:futures"]
6565
combined-transport = []
6666
quinn-flume-socket = ["dep:flume", "dep:quinn", "dep:quinn-udp", "dep:bytes", "dep:tokio-util"]
6767
macros = []
68-
default = ["flume-transport", "async-channel-transport"]
68+
default = ["flume-transport", "tokio-mpsc-transport"]
6969

7070
[package.metadata.docs.rs]
7171
all-features = true

src/transport/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ use std::{
77
fmt::{self, Debug, Display},
88
net::SocketAddr,
99
};
10-
#[cfg(feature = "async-channel-transport")]
11-
pub mod async_channel;
1210
#[cfg(feature = "flume-transport")]
1311
pub mod boxed;
1412
#[cfg(feature = "combined-transport")]
@@ -23,6 +21,8 @@ pub mod interprocess;
2321
pub mod quinn;
2422
#[cfg(feature = "quinn-flume-socket")]
2523
pub mod quinn_flume_socket;
24+
#[cfg(feature = "tokio-mpsc-transport")]
25+
pub mod tokio_mpsc;
2626

2727
pub mod misc;
2828

src/transport/async_channel.rs renamed to src/transport/tokio_mpsc.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use futures_lite::Stream;
44
use futures_sink::Sink;
55

66
use crate::{
7-
transport::{Connection, ConnectionErrors, LocalAddr, ServerEndpoint},
7+
transport::{self, ConnectionErrors, LocalAddr},
88
RpcMessage, Service,
99
};
1010
use core::fmt;
@@ -100,28 +100,28 @@ impl error::Error for RecvError {}
100100
/// A `tokio::sync::mpsc` based server endpoint.
101101
///
102102
/// Created using [connection].
103-
pub struct MpscServerEndpoint<S: Service> {
103+
pub struct ServerEndpoint<S: Service> {
104104
#[allow(clippy::type_complexity)]
105105
stream: Arc<Mutex<mpsc::Receiver<(SendSink<S::Res>, RecvStream<S::Req>)>>>,
106106
}
107107

108-
impl<S: Service> Clone for MpscServerEndpoint<S> {
108+
impl<S: Service> Clone for ServerEndpoint<S> {
109109
fn clone(&self) -> Self {
110110
Self {
111111
stream: self.stream.clone(),
112112
}
113113
}
114114
}
115115

116-
impl<S: Service> fmt::Debug for MpscServerEndpoint<S> {
116+
impl<S: Service> fmt::Debug for ServerEndpoint<S> {
117117
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
118-
f.debug_struct("MpscServerEndpoint")
118+
f.debug_struct("ServerEndpoint")
119119
.field("stream", &self.stream)
120120
.finish()
121121
}
122122
}
123123

124-
impl<S: Service> ConnectionErrors for MpscServerEndpoint<S> {
124+
impl<S: Service> ConnectionErrors for ServerEndpoint<S> {
125125
type SendError = self::SendError;
126126

127127
type RecvError = self::RecvError;
@@ -131,12 +131,12 @@ impl<S: Service> ConnectionErrors for MpscServerEndpoint<S> {
131131

132132
type Socket<In, Out> = (self::SendSink<Out>, self::RecvStream<In>);
133133

134-
impl<S: Service> ConnectionCommon<S::Req, S::Res> for MpscServerEndpoint<S> {
134+
impl<S: Service> ConnectionCommon<S::Req, S::Res> for ServerEndpoint<S> {
135135
type SendSink = SendSink<S::Res>;
136136
type RecvStream = RecvStream<S::Req>;
137137
}
138138

139-
impl<S: Service> ServerEndpoint<S::Req, S::Res> for MpscServerEndpoint<S> {
139+
impl<S: Service> transport::ServerEndpoint<S::Req, S::Res> for ServerEndpoint<S> {
140140
async fn accept_bi(&self) -> Result<(Self::SendSink, Self::RecvStream), AcceptBiError> {
141141
let (send, recv) = self
142142
.stream
@@ -153,20 +153,20 @@ impl<S: Service> ServerEndpoint<S::Req, S::Res> for MpscServerEndpoint<S> {
153153
}
154154
}
155155

156-
impl<S: Service> ConnectionErrors for MpscConnection<S> {
156+
impl<S: Service> ConnectionErrors for Connection<S> {
157157
type SendError = self::SendError;
158158

159159
type RecvError = self::RecvError;
160160

161161
type OpenError = self::OpenBiError;
162162
}
163163

164-
impl<S: Service> ConnectionCommon<S::Res, S::Req> for MpscConnection<S> {
164+
impl<S: Service> ConnectionCommon<S::Res, S::Req> for Connection<S> {
165165
type SendSink = SendSink<S::Req>;
166166
type RecvStream = RecvStream<S::Res>;
167167
}
168168

169-
impl<S: Service> Connection<S::Res, S::Req> for MpscConnection<S> {
169+
impl<S: Service> transport::Connection<S::Res, S::Req> for Connection<S> {
170170
async fn open_bi(&self) -> result::Result<Socket<S::Res, S::Req>, self::OpenBiError> {
171171
let (local_send, remote_recv) = mpsc::channel::<S::Req>(128);
172172
let (remote_send, local_recv) = mpsc::channel::<S::Res>(128);
@@ -186,25 +186,25 @@ impl<S: Service> Connection<S::Res, S::Req> for MpscConnection<S> {
186186
}
187187
}
188188

189-
/// A mpsc based connection to a server endpoint.
189+
/// A tokio::sync::mpsc based connection to a server endpoint.
190190
///
191191
/// Created using [connection].
192-
pub struct MpscConnection<S: Service> {
192+
pub struct Connection<S: Service> {
193193
#[allow(clippy::type_complexity)]
194194
sink: mpsc::Sender<(SendSink<S::Res>, RecvStream<S::Req>)>,
195195
}
196196

197-
impl<S: Service> Clone for MpscConnection<S> {
197+
impl<S: Service> Clone for Connection<S> {
198198
fn clone(&self) -> Self {
199199
Self {
200200
sink: self.sink.clone(),
201201
}
202202
}
203203
}
204204

205-
impl<S: Service> fmt::Debug for MpscConnection<S> {
205+
impl<S: Service> fmt::Debug for Connection<S> {
206206
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
207-
f.debug_struct("MpscClientChannel")
207+
f.debug_struct("ClientChannel")
208208
.field("sink", &self.sink)
209209
.finish()
210210
}
@@ -277,12 +277,12 @@ impl std::error::Error for CreateChannelError {}
277277
/// Create a mpsc server endpoint and a connected mpsc client channel.
278278
///
279279
/// `buffer` the size of the buffer for each channel. Keep this at a low value to get backpressure
280-
pub fn connection<S: Service>(buffer: usize) -> (MpscServerEndpoint<S>, MpscConnection<S>) {
280+
pub fn connection<S: Service>(buffer: usize) -> (ServerEndpoint<S>, Connection<S>) {
281281
let (sink, stream) = mpsc::channel(buffer);
282282
(
283-
MpscServerEndpoint {
283+
ServerEndpoint {
284284
stream: Arc::new(Mutex::new(stream)),
285285
},
286-
MpscConnection { sink },
286+
Connection { sink },
287287
)
288288
}
File renamed without changes.

0 commit comments

Comments
 (0)