1use crate::{BoxMultipartWrite, LocalBoxMultipartWrite};
6
7use futures_core::future::Future;
8use std::pin::Pin;
9use std::task::{Context, Poll};
10
11pub use crate::MultipartWrite;
12
13mod bootstrapped;
14pub use bootstrapped::Bootstrapped;
15
16mod buffered;
17pub use buffered::Buffered;
18
19mod complete;
20pub use complete::Complete;
21
22mod fanout;
23pub use fanout::Fanout;
24
25mod feed;
26pub use feed::Feed;
27
28mod fold_ret;
29pub use fold_ret::FoldRet;
30
31mod flush;
32pub use flush::Flush;
33
34mod map;
35pub use map::Map;
36
37mod map_err;
38pub use map_err::MapErr;
39
40mod map_part;
41pub use map_part::MapPart;
42
43mod map_ret;
44pub use map_ret::MapRet;
45
46mod send_part;
47pub use send_part::SendPart;
48
49mod then;
50pub use then::Then;
51
52mod with;
53pub use with::With;
54
55impl<Wr: MultipartWrite<Part>, Part> MultipartWriteExt<Part> for Wr {}
56
57pub trait MultipartWriteExt<Part>: MultipartWrite<Part> {
60 fn bootstrapped<S, F, Fut>(self, s: S, f: F) -> Bootstrapped<Self, S, F, Fut>
68 where
69 F: FnMut(&mut S) -> Fut,
70 Fut: Future<Output = Result<Option<Self>, Self::Error>>,
71 Self: Sized,
72 {
73 Bootstrapped::new(self, s, f)
74 }
75
76 fn boxed<'a>(self) -> BoxMultipartWrite<'a, Part, Self::Ret, Self::Output, Self::Error>
78 where
79 Self: Sized + Send + 'a,
80 {
81 Box::pin(self)
82 }
83
84 fn boxed_local<'a>(
88 self,
89 ) -> LocalBoxMultipartWrite<'a, Part, Self::Ret, Self::Output, Self::Error>
90 where
91 Self: Sized + 'a,
92 {
93 Box::pin(self)
94 }
95
96 fn buffered(self, capacity: impl Into<Option<usize>>) -> Buffered<Self, Part>
101 where
102 Self: Sized,
103 {
104 Buffered::new(self, capacity.into().unwrap_or_default())
105 }
106
107 fn complete(&mut self) -> Complete<'_, Self, Part>
110 where
111 Self: Unpin,
112 {
113 Complete::new(self)
114 }
115
116 fn fanout<U>(self, other: U) -> Fanout<Self, U, Part>
120 where
121 Part: Clone,
122 U: MultipartWrite<Part, Error = Self::Error>,
123 Self: Sized,
124 {
125 Fanout::new(self, other)
126 }
127
128 fn feed(&mut self, part: Part) -> Feed<'_, Self, Part>
135 where
136 Self: Unpin,
137 {
138 Feed::new(self, part)
139 }
140
141 fn flush(&mut self) -> Flush<'_, Self, Part>
143 where
144 Self: Unpin,
145 {
146 Flush::new(self)
147 }
148
149 fn fold_ret<T, F>(self, id: T, f: F) -> FoldRet<Self, F, T>
153 where
154 F: FnMut(T, &Self::Ret) -> T,
155 Self: Sized,
156 {
157 FoldRet::new(self, id, f)
158 }
159
160 fn map<U, F>(self, f: F) -> Map<Self, F>
163 where
164 F: FnMut(Self::Output) -> U,
165 Self: Sized,
166 {
167 Map::new(self, f)
168 }
169
170 fn map_err<E, F>(self, f: F) -> MapErr<Self, F>
173 where
174 F: FnMut(Self::Error) -> E,
175 Self: Sized,
176 {
177 MapErr::new(self, f)
178 }
179
180 fn map_part<U, F>(self, f: F) -> MapPart<Self, F>
183 where
184 F: FnMut(U) -> Result<Part, Self::Error>,
185 Self: MultipartWrite<Part> + Sized,
186 {
187 MapPart::new(self, f)
188 }
189
190 fn map_ret<U, F>(self, f: F) -> MapRet<Self, F>
193 where
194 F: FnMut(Self::Ret) -> U,
195 Self: Sized,
196 {
197 MapRet::new(self, f)
198 }
199
200 #[must_use = "futures do nothing unless polled"]
204 fn poll_ready_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
205 where
206 Self: Unpin,
207 {
208 Pin::new(self).poll_ready(cx)
209 }
210
211 #[must_use = "futures do nothing unless polled"]
215 fn poll_flush_unpin(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
216 where
217 Self: Unpin,
218 {
219 Pin::new(self).poll_flush(cx)
220 }
221
222 #[must_use = "futures do nothing unless polled"]
226 fn poll_complete_unpin(
227 &mut self,
228 cx: &mut Context<'_>,
229 ) -> Poll<Result<Self::Output, Self::Error>>
230 where
231 Self: Unpin,
232 {
233 Pin::new(self).poll_complete(cx)
234 }
235
236 fn send_part(&mut self, part: Part) -> SendPart<'_, Self, Part>
239 where
240 Self: Unpin,
241 {
242 SendPart::new(self, part)
243 }
244
245 fn then<U, F, Fut>(self, f: F) -> Then<Self, F, Fut>
247 where
248 F: FnMut(Self::Output) -> Fut,
249 Fut: Future<Output = U>,
250 Self: Sized,
251 {
252 Then::new(self, f)
253 }
254
255 fn with<U, Fut, F, E>(self, f: F) -> With<Self, Part, U, Fut, F>
260 where
261 F: FnMut(U) -> Fut,
262 Fut: Future<Output = Result<Part, E>>,
263 E: From<Self::Error>,
264 Self: Sized,
265 {
266 With::new(self, f)
267 }
268}