Skip to content

Commit 69c48de

Browse files
committed
Rename Sink::SinkError to Sink::Error
1 parent 9a0be7e commit 69c48de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+257
-259
lines changed

futures-channel/src/mpsc/sink_impl.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@ use futures_sink::Sink;
44
use std::pin::Pin;
55

66
impl<T> Sink<T> for Sender<T> {
7-
type SinkError = SendError;
7+
type Error = SendError;
88

99
fn poll_ready(
1010
mut self: Pin<&mut Self>,
1111
cx: &mut Context<'_>,
12-
) -> Poll<Result<(), Self::SinkError>> {
12+
) -> Poll<Result<(), Self::Error>> {
1313
(*self).poll_ready(cx)
1414
}
1515

1616
fn start_send(
1717
mut self: Pin<&mut Self>,
1818
msg: T,
19-
) -> Result<(), Self::SinkError> {
19+
) -> Result<(), Self::Error> {
2020
(*self).start_send(msg)
2121
}
2222

2323
fn poll_flush(
2424
mut self: Pin<&mut Self>,
2525
cx: &mut Context<'_>,
26-
) -> Poll<Result<(), Self::SinkError>> {
26+
) -> Poll<Result<(), Self::Error>> {
2727
match (*self).poll_ready(cx) {
2828
Poll::Ready(Err(ref e)) if e.is_disconnected() => {
2929
// If the receiver disconnected, we consider the sink to be flushed.
@@ -36,71 +36,71 @@ impl<T> Sink<T> for Sender<T> {
3636
fn poll_close(
3737
mut self: Pin<&mut Self>,
3838
_: &mut Context<'_>,
39-
) -> Poll<Result<(), Self::SinkError>> {
39+
) -> Poll<Result<(), Self::Error>> {
4040
self.disconnect();
4141
Poll::Ready(Ok(()))
4242
}
4343
}
4444

4545
impl<T> Sink<T> for UnboundedSender<T> {
46-
type SinkError = SendError;
46+
type Error = SendError;
4747

4848
fn poll_ready(
4949
self: Pin<&mut Self>,
5050
cx: &mut Context<'_>,
51-
) -> Poll<Result<(), Self::SinkError>> {
51+
) -> Poll<Result<(), Self::Error>> {
5252
UnboundedSender::poll_ready(&*self, cx)
5353
}
5454

5555
fn start_send(
5656
mut self: Pin<&mut Self>,
5757
msg: T,
58-
) -> Result<(), Self::SinkError> {
58+
) -> Result<(), Self::Error> {
5959
UnboundedSender::start_send(&mut *self, msg)
6060
}
6161

6262
fn poll_flush(
6363
self: Pin<&mut Self>,
6464
_: &mut Context<'_>,
65-
) -> Poll<Result<(), Self::SinkError>> {
65+
) -> Poll<Result<(), Self::Error>> {
6666
Poll::Ready(Ok(()))
6767
}
6868

6969
fn poll_close(
7070
mut self: Pin<&mut Self>,
7171
_: &mut Context<'_>,
72-
) -> Poll<Result<(), Self::SinkError>> {
72+
) -> Poll<Result<(), Self::Error>> {
7373
self.disconnect();
7474
Poll::Ready(Ok(()))
7575
}
7676
}
7777

7878
impl<T> Sink<T> for &UnboundedSender<T> {
79-
type SinkError = SendError;
79+
type Error = SendError;
8080

8181
fn poll_ready(
8282
self: Pin<&mut Self>,
8383
cx: &mut Context<'_>,
84-
) -> Poll<Result<(), Self::SinkError>> {
84+
) -> Poll<Result<(), Self::Error>> {
8585
UnboundedSender::poll_ready(*self, cx)
8686
}
8787

88-
fn start_send(self: Pin<&mut Self>, msg: T) -> Result<(), Self::SinkError> {
88+
fn start_send(self: Pin<&mut Self>, msg: T) -> Result<(), Self::Error> {
8989
self.unbounded_send(msg)
9090
.map_err(TrySendError::into_send_error)
9191
}
9292

9393
fn poll_flush(
9494
self: Pin<&mut Self>,
9595
_: &mut Context<'_>,
96-
) -> Poll<Result<(), Self::SinkError>> {
96+
) -> Poll<Result<(), Self::Error>> {
9797
Poll::Ready(Ok(()))
9898
}
9999

100100
fn poll_close(
101101
self: Pin<&mut Self>,
102102
_: &mut Context<'_>,
103-
) -> Poll<Result<(), Self::SinkError>> {
103+
) -> Poll<Result<(), Self::Error>> {
104104
self.close_channel();
105105
Poll::Ready(Ok(()))
106106
}

futures-sink/src/lib.rs

+30-30
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ use core::pin::Pin;
4949
#[must_use = "sinks do nothing unless polled"]
5050
pub trait Sink<Item> {
5151
/// The type of value produced by the sink when an error occurs.
52-
type SinkError;
52+
type Error;
5353

5454
/// Attempts to prepare the `Sink` to receive a value.
5555
///
@@ -63,7 +63,7 @@ pub trait Sink<Item> {
6363
///
6464
/// In most cases, if the sink encounters an error, the sink will
6565
/// permanently be unable to receive items.
66-
fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>>;
66+
fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>;
6767

6868
/// Begin the process of sending a value to the sink.
6969
/// Each call to this function must be preceded by a successful call to
@@ -85,7 +85,7 @@ pub trait Sink<Item> {
8585
/// In most cases, if the sink encounters an error, the sink will
8686
/// permanently be unable to receive items.
8787
fn start_send(self: Pin<&mut Self>, item: Item)
88-
-> Result<(), Self::SinkError>;
88+
-> Result<(), Self::Error>;
8989

9090
/// Flush any remaining output from this sink.
9191
///
@@ -99,7 +99,7 @@ pub trait Sink<Item> {
9999
///
100100
/// In most cases, if the sink encounters an error, the sink will
101101
/// permanently be unable to receive items.
102-
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>>;
102+
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>;
103103

104104
/// Flush any remaining output and close this sink, if necessary.
105105
///
@@ -112,25 +112,25 @@ pub trait Sink<Item> {
112112
///
113113
/// If this function encounters an error, the sink should be considered to
114114
/// have failed permanently, and no more `Sink` methods should be called.
115-
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>>;
115+
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>;
116116
}
117117

118118
impl<S: ?Sized + Sink<Item> + Unpin, Item> Sink<Item> for &mut S {
119-
type SinkError = S::SinkError;
119+
type Error = S::Error;
120120

121-
fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>> {
121+
fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
122122
Pin::new(&mut **self).poll_ready(cx)
123123
}
124124

125-
fn start_send(mut self: Pin<&mut Self>, item: Item) -> Result<(), Self::SinkError> {
125+
fn start_send(mut self: Pin<&mut Self>, item: Item) -> Result<(), Self::Error> {
126126
Pin::new(&mut **self).start_send(item)
127127
}
128128

129-
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>> {
129+
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
130130
Pin::new(&mut **self).poll_flush(cx)
131131
}
132132

133-
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>> {
133+
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
134134
Pin::new(&mut **self).poll_close(cx)
135135
}
136136
}
@@ -140,21 +140,21 @@ where
140140
P: DerefMut + Unpin,
141141
P::Target: Sink<Item>,
142142
{
143-
type SinkError = <P::Target as Sink<Item>>::SinkError;
143+
type Error = <P::Target as Sink<Item>>::Error;
144144

145-
fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>> {
145+
fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
146146
self.get_mut().as_mut().poll_ready(cx)
147147
}
148148

149-
fn start_send(self: Pin<&mut Self>, item: Item) -> Result<(), Self::SinkError> {
149+
fn start_send(self: Pin<&mut Self>, item: Item) -> Result<(), Self::Error> {
150150
self.get_mut().as_mut().start_send(item)
151151
}
152152

153-
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>> {
153+
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
154154
self.get_mut().as_mut().poll_flush(cx)
155155
}
156156

157-
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>> {
157+
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
158158
self.get_mut().as_mut().poll_close(cx)
159159
}
160160
}
@@ -165,65 +165,65 @@ mod if_alloc {
165165
use futures_core::never::Never;
166166

167167
impl<T> Sink<T> for alloc::vec::Vec<T> {
168-
type SinkError = Never;
168+
type Error = Never;
169169

170-
fn poll_ready(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>> {
170+
fn poll_ready(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
171171
Poll::Ready(Ok(()))
172172
}
173173

174-
fn start_send(self: Pin<&mut Self>, item: T) -> Result<(), Self::SinkError> {
174+
fn start_send(self: Pin<&mut Self>, item: T) -> Result<(), Self::Error> {
175175
// TODO: impl<T> Unpin for Vec<T> {}
176176
unsafe { self.get_unchecked_mut() }.push(item);
177177
Ok(())
178178
}
179179

180-
fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>> {
180+
fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
181181
Poll::Ready(Ok(()))
182182
}
183183

184-
fn poll_close(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>> {
184+
fn poll_close(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
185185
Poll::Ready(Ok(()))
186186
}
187187
}
188188

189189
impl<T> Sink<T> for alloc::collections::VecDeque<T> {
190-
type SinkError = Never;
190+
type Error = Never;
191191

192-
fn poll_ready(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>> {
192+
fn poll_ready(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
193193
Poll::Ready(Ok(()))
194194
}
195195

196-
fn start_send(self: Pin<&mut Self>, item: T) -> Result<(), Self::SinkError> {
196+
fn start_send(self: Pin<&mut Self>, item: T) -> Result<(), Self::Error> {
197197
// TODO: impl<T> Unpin for Vec<T> {}
198198
unsafe { self.get_unchecked_mut() }.push_back(item);
199199
Ok(())
200200
}
201201

202-
fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>> {
202+
fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
203203
Poll::Ready(Ok(()))
204204
}
205205

206-
fn poll_close(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>> {
206+
fn poll_close(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
207207
Poll::Ready(Ok(()))
208208
}
209209
}
210210

211211
impl<S: ?Sized + Sink<Item> + Unpin, Item> Sink<Item> for alloc::boxed::Box<S> {
212-
type SinkError = S::SinkError;
212+
type Error = S::Error;
213213

214-
fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>> {
214+
fn poll_ready(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
215215
Pin::new(&mut **self).poll_ready(cx)
216216
}
217217

218-
fn start_send(mut self: Pin<&mut Self>, item: Item) -> Result<(), Self::SinkError> {
218+
fn start_send(mut self: Pin<&mut Self>, item: Item) -> Result<(), Self::Error> {
219219
Pin::new(&mut **self).start_send(item)
220220
}
221221

222-
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>> {
222+
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
223223
Pin::new(&mut **self).poll_flush(cx)
224224
}
225225

226-
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>> {
226+
fn poll_close(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
227227
Pin::new(&mut **self).poll_close(cx)
228228
}
229229
}

futures-util/src/compat/compat01as03.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ pub trait Sink01CompatExt: Sink01 {
105105
/// Converts a futures 0.1
106106
/// [`Sink<SinkItem = T, SinkError = E>`](futures_01::sink::Sink)
107107
/// into a futures 0.3
108-
/// [`Sink<SinkItem = T, SinkError = E>`](futures_sink::Sink).
108+
/// [`Sink<T, Error = E>`](futures_sink::Sink).
109109
///
110110
/// ```
111111
/// #![feature(async_await)]
@@ -222,12 +222,12 @@ impl<S, SinkItem> Sink03<SinkItem> for Compat01As03Sink<S, SinkItem>
222222
where
223223
S: Sink01<SinkItem = SinkItem>,
224224
{
225-
type SinkError = S::SinkError;
225+
type Error = S::SinkError;
226226

227227
fn start_send(
228228
mut self: Pin<&mut Self>,
229229
item: SinkItem,
230-
) -> Result<(), Self::SinkError> {
230+
) -> Result<(), Self::Error> {
231231
debug_assert!(self.buffer.is_none());
232232
self.buffer = Some(item);
233233
Ok(())
@@ -236,7 +236,7 @@ where
236236
fn poll_ready(
237237
mut self: Pin<&mut Self>,
238238
cx: &mut Context<'_>,
239-
) -> task03::Poll<Result<(), Self::SinkError>> {
239+
) -> task03::Poll<Result<(), Self::Error>> {
240240
match self.buffer.take() {
241241
Some(item) => match self.in_notify(cx, |f| f.start_send(item))? {
242242
AsyncSink01::Ready => task03::Poll::Ready(Ok(())),
@@ -252,7 +252,7 @@ where
252252
fn poll_flush(
253253
mut self: Pin<&mut Self>,
254254
cx: &mut Context<'_>,
255-
) -> task03::Poll<Result<(), Self::SinkError>> {
255+
) -> task03::Poll<Result<(), Self::Error>> {
256256
let item = self.buffer.take();
257257
match self.in_notify(cx, |f| match item {
258258
Some(i) => match f.start_send(i)? {
@@ -274,7 +274,7 @@ where
274274
fn poll_close(
275275
mut self: Pin<&mut Self>,
276276
cx: &mut Context<'_>,
277-
) -> task03::Poll<Result<(), Self::SinkError>> {
277+
) -> task03::Poll<Result<(), Self::Error>> {
278278
let item = self.buffer.take();
279279
let close_started = self.close_started;
280280

futures-util/src/compat/compat03as01.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ where
121121
T: Sink03<Item> + Unpin,
122122
{
123123
type SinkItem = Item;
124-
type SinkError = T::SinkError;
124+
type SinkError = T::Error;
125125

126126
fn start_send(
127127
&mut self,

futures-util/src/future/either.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ where
111111
impl<A, B, Item> Sink<Item> for Either<A, B>
112112
where
113113
A: Sink<Item>,
114-
B: Sink<Item, SinkError = A::SinkError>,
114+
B: Sink<Item, Error = A::Error>,
115115
{
116-
type SinkError = A::SinkError;
116+
type Error = A::Error;
117117

118-
fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>> {
118+
fn poll_ready(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
119119
unsafe {
120120
match self.get_unchecked_mut() {
121121
Either::Left(x) => Pin::new_unchecked(x).poll_ready(cx),
@@ -124,7 +124,7 @@ where
124124
}
125125
}
126126

127-
fn start_send(self: Pin<&mut Self>, item: Item) -> Result<(), Self::SinkError> {
127+
fn start_send(self: Pin<&mut Self>, item: Item) -> Result<(), Self::Error> {
128128
unsafe {
129129
match self.get_unchecked_mut() {
130130
Either::Left(x) => Pin::new_unchecked(x).start_send(item),
@@ -133,7 +133,7 @@ where
133133
}
134134
}
135135

136-
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>> {
136+
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
137137
unsafe {
138138
match self.get_unchecked_mut() {
139139
Either::Left(x) => Pin::new_unchecked(x).poll_flush(cx),
@@ -142,7 +142,7 @@ where
142142
}
143143
}
144144

145-
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::SinkError>> {
145+
fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
146146
unsafe {
147147
match self.get_unchecked_mut() {
148148
Either::Left(x) => Pin::new_unchecked(x).poll_close(cx),

0 commit comments

Comments
 (0)