1use futures_core::future::Future;
6use std::pin::Pin;
7use std::task::{Context, Poll};
8
9pub use crate::{BoxMultipartWrite, LocalBoxMultipartWrite, MultipartWrite};
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 map_err;
42pub use map_err::MapErr;
43
44mod map_ok;
45pub use map_ok::MapOk;
46
47mod returning;
48pub use returning::Returning;
49
50mod send_part;
51pub use send_part::SendPart;
52
53mod with;
54pub use with::With;
55
56impl<Wr: MultipartWrite<Part>, Part> MultipartWriteExt<Part> for Wr {}
57
58pub trait MultipartWriteExt<Part>: MultipartWrite<Part> {
61 fn and_then<T, E, Fut, F>(self, f: F) -> AndThen<Self, Fut, F>
68 where
69 F: FnMut(Self::Output) -> Fut,
70 Fut: Future<Output = Result<T, E>>,
71 E: From<Self::Error>,
72 Self: Sized,
73 {
74 AndThen::new(self, f)
75 }
76
77 fn boxed<'a>(self) -> BoxMultipartWrite<'a, Part, Self::Ret, Self::Output, Self::Error>
79 where
80 Self: Sized + Send + 'a,
81 {
82 Box::pin(self)
83 }
84
85 fn boxed_local<'a>(
89 self,
90 ) -> LocalBoxMultipartWrite<'a, Part, Self::Ret, Self::Output, Self::Error>
91 where
92 Self: Sized + 'a,
93 {
94 Box::pin(self)
95 }
96
97 fn buffered(self, capacity: impl Into<Option<usize>>) -> Buffered<Self, Part>
102 where
103 Self: Sized,
104 {
105 Buffered::new(self, capacity.into().unwrap_or_default())
106 }
107
108 fn complete(&mut self) -> Complete<'_, Self, Part>
111 where
112 Self: Unpin,
113 {
114 Complete::new(self)
115 }
116
117 fn fanout<U>(self, other: U) -> Fanout<Self, U, Part>
121 where
122 Part: Clone,
123 U: MultipartWrite<Part, Error = Self::Error>,
124 Self: Sized,
125 {
126 Fanout::new(self, other)
127 }
128
129 fn feed(&mut self, part: Part) -> Feed<'_, Self, Part>
136 where
137 Self: Unpin,
138 {
139 Feed::new(self, part)
140 }
141
142 fn filter<F>(self, f: F) -> Filter<Self, F>
148 where
149 F: FnMut(&Part) -> bool,
150 Self: Sized,
151 {
152 Filter::new(self, f)
153 }
154
155 fn filter_map<U, F>(self, f: F) -> FilterMap<Self, F>
161 where
162 F: FnMut(U) -> Option<Part>,
163 Self: Sized,
164 {
165 FilterMap::new(self, f)
166 }
167
168 fn flush(&mut self) -> Flush<'_, Self, Part>
170 where
171 Self: Unpin,
172 {
173 Flush::new(self)
174 }
175
176 fn fold_ret<T, F>(self, id: T, f: F) -> FoldRet<Self, T, F>
180 where
181 F: FnMut(T, &Self::Ret) -> T,
182 Self: Sized,
183 {
184 FoldRet::new(self, id, f)
185 }
186
187 fn map_ok<U, F>(self, f: F) -> MapOk<Self, F>
190 where
191 F: FnMut(Self::Output) -> U,
192 Self: Sized,
193 {
194 MapOk::new(self, f)
195 }
196
197 fn map_err<E, F>(self, f: F) -> MapErr<Self, F>
200 where
201 F: FnMut(Self::Error) -> E,
202 Self: Sized,
203 {
204 MapErr::new(self, f)
205 }
206
207 fn returning<U, F>(self, f: F) -> Returning<Self, F>
210 where
211 F: FnMut(Self::Ret) -> U,
212 Self: Sized,
213 {
214 Returning::new(self, f)
215 }
216
217 #[must_use = "futures do nothing unless polled"]
220 fn poll_ready_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
221 where
222 Self: Unpin,
223 {
224 Pin::new(self).poll_ready(cx)
225 }
226
227 #[must_use = "futures do nothing unless polled"]
230 fn poll_flush_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
231 where
232 Self: Unpin,
233 {
234 Pin::new(self).poll_flush(cx)
235 }
236
237 #[must_use = "futures do nothing unless polled"]
240 fn poll_complete_unpin(
241 &mut self,
242 cx: &mut Context<'_>,
243 ) -> Poll<Result<Self::Output, Self::Error>>
244 where
245 Self: Unpin,
246 {
247 Pin::new(self).poll_complete(cx)
248 }
249
250 fn send_part(&mut self, part: Part) -> SendPart<'_, Self, Part>
253 where
254 Self: Unpin,
255 {
256 SendPart::new(self, part)
257 }
258
259 fn with<U, E, Fut, F>(self, f: F) -> With<Self, Part, Fut, F>
265 where
266 F: FnMut(U) -> Fut,
267 Fut: Future<Output = Result<Part, E>>,
268 E: From<Self::Error>,
269 Self: Sized,
270 {
271 With::new(self, f)
272 }
273}