1use crate::{BoxMultipartWrite, LocalBoxMultipartWrite, MultipartWrite};
6
7use futures_core::future::Future;
8use std::pin::Pin;
9use std::task::{Context, Poll};
10
11mod and_then;
12pub use and_then::AndThen;
13
14mod buffered;
15pub use buffered::Buffered;
16
17mod complete;
18pub use complete::Complete;
19
20mod extend;
21pub use extend::{Extend, extend};
22
23mod fanout;
24pub use fanout::Fanout;
25
26mod feed;
27pub use feed::Feed;
28
29mod filter;
30pub use filter::Filter;
31
32mod filter_map;
33pub use filter_map::FilterMap;
34
35mod fold_ret;
36pub use fold_ret::FoldRet;
37
38mod flush;
39pub use flush::Flush;
40
41mod fuse;
42pub use fuse::Fuse;
43
44mod map_err;
45pub use map_err::MapErr;
46
47mod map_ret;
48pub use map_ret::MapRet;
49
50mod map_ok;
51pub use map_ok::MapOk;
52
53mod send_part;
54pub use send_part::SendPart;
55
56mod then;
57pub use then::Then;
58
59mod with;
60pub use with::With;
61
62impl<Wr: MultipartWrite<Part>, Part> MultipartWriteExt<Part> for Wr {}
63
64pub trait MultipartWriteExt<Part>: MultipartWrite<Part> {
67 fn and_then<T, E, Fut, F>(self, f: F) -> AndThen<Self, Fut, F>
74 where
75 F: FnMut(Self::Output) -> Fut,
76 Fut: Future<Output = Result<T, E>>,
77 E: From<Self::Error>,
78 Self: Sized,
79 {
80 AndThen::new(self, f)
81 }
82
83 fn boxed<'a>(self) -> BoxMultipartWrite<'a, Part, Self::Ret, Self::Output, Self::Error>
85 where
86 Self: Sized + Send + 'a,
87 {
88 Box::pin(self)
89 }
90
91 fn boxed_local<'a>(
95 self,
96 ) -> LocalBoxMultipartWrite<'a, Part, Self::Ret, Self::Output, Self::Error>
97 where
98 Self: Sized + 'a,
99 {
100 Box::pin(self)
101 }
102
103 fn buffered(self, capacity: impl Into<Option<usize>>) -> Buffered<Self, Part>
108 where
109 Self: Sized,
110 {
111 Buffered::new(self, capacity.into().unwrap_or_default())
112 }
113
114 fn complete(&mut self) -> Complete<'_, Self, Part>
117 where
118 Self: Unpin,
119 {
120 Complete::new(self)
121 }
122
123 fn fanout<U>(self, other: U) -> Fanout<Self, U, Part>
127 where
128 Part: Clone,
129 U: MultipartWrite<Part, Error = Self::Error>,
130 Self: Sized,
131 {
132 Fanout::new(self, other)
133 }
134
135 fn feed(&mut self, part: Part) -> Feed<'_, Self, Part>
142 where
143 Self: Unpin,
144 {
145 Feed::new(self, part)
146 }
147
148 fn filter<F>(self, f: F) -> Filter<Self, F>
154 where
155 F: FnMut(&Part) -> bool,
156 Self: Sized,
157 {
158 Filter::new(self, f)
159 }
160
161 fn filter_map<U, F>(self, f: F) -> FilterMap<Self, F>
167 where
168 F: FnMut(U) -> Option<Part>,
169 Self: Sized,
170 {
171 FilterMap::new(self, f)
172 }
173
174 fn flush(&mut self) -> Flush<'_, Self, Part>
176 where
177 Self: Unpin,
178 {
179 Flush::new(self)
180 }
181
182 fn fold_ret<T, F>(self, id: T, f: F) -> FoldRet<Self, T, F>
186 where
187 F: FnMut(T, &Self::Ret) -> T,
188 Self: Sized,
189 {
190 FoldRet::new(self, id, f)
191 }
192
193 fn fuse<F>(self, f: F) -> Fuse<Self, F>
199 where
200 F: FnMut(&Self::Output) -> bool,
201 Self: Sized,
202 {
203 Fuse::new(self, f)
204 }
205
206 fn map_err<E, F>(self, f: F) -> MapErr<Self, F>
209 where
210 F: FnMut(Self::Error) -> E,
211 Self: Sized,
212 {
213 MapErr::new(self, f)
214 }
215
216 fn map_ok<U, F>(self, f: F) -> MapOk<Self, F>
219 where
220 F: FnMut(Self::Output) -> U,
221 Self: Sized,
222 {
223 MapOk::new(self, f)
224 }
225
226 fn map_ret<U, F>(self, f: F) -> MapRet<Self, F>
229 where
230 F: FnMut(Self::Ret) -> U,
231 Self: Sized,
232 {
233 MapRet::new(self, f)
234 }
235
236 #[must_use = "futures do nothing unless polled"]
239 fn poll_ready_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
240 where
241 Self: Unpin,
242 {
243 Pin::new(self).poll_ready(cx)
244 }
245
246 #[must_use = "futures do nothing unless polled"]
249 fn poll_flush_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
250 where
251 Self: Unpin,
252 {
253 Pin::new(self).poll_flush(cx)
254 }
255
256 #[must_use = "futures do nothing unless polled"]
259 fn poll_complete_unpin(
260 &mut self,
261 cx: &mut Context<'_>,
262 ) -> Poll<Result<Self::Output, Self::Error>>
263 where
264 Self: Unpin,
265 {
266 Pin::new(self).poll_complete(cx)
267 }
268
269 fn send_part(&mut self, part: Part) -> SendPart<'_, Self, Part>
272 where
273 Self: Unpin,
274 {
275 SendPart::new(self, part)
276 }
277
278 fn then<T, E, Fut, F>(self, f: F) -> Then<Self, Fut, F>
281 where
282 F: FnMut(Result<Self::Output, Self::Error>) -> Fut,
283 Fut: Future<Output = Result<T, E>>,
284 E: From<Self::Error>,
285 Self: Sized,
286 {
287 Then::new(self, f)
288 }
289
290 fn with<U, E, Fut, F>(self, f: F) -> With<Self, Part, Fut, F>
296 where
297 F: FnMut(U) -> Fut,
298 Fut: Future<Output = Result<Part, E>>,
299 E: From<Self::Error>,
300 Self: Sized,
301 {
302 With::new(self, f)
303 }
304}