1mod sink_ext;
3
4use std::future::Future;
5
6pub use sink_ext::SinkExt;
7
8#[must_use = "sinks do nothing unless polled"]
10pub trait Sink<Item> {
11 type Error;
13
14 fn send(&mut self, item: Item) -> impl Future<Output = Result<(), Self::Error>>;
16
17 fn flush(&mut self) -> impl Future<Output = Result<(), Self::Error>>;
19
20 fn close(&mut self) -> impl Future<Output = Result<(), Self::Error>>;
22}
23
24impl<T, S: ?Sized + Sink<T>> Sink<T> for &mut S {
25 type Error = S::Error;
26
27 fn send(&mut self, item: T) -> impl Future<Output = Result<(), Self::Error>> {
28 (**self).send(item)
29 }
30
31 fn flush(&mut self) -> impl Future<Output = Result<(), Self::Error>> {
32 (**self).flush()
33 }
34
35 fn close(&mut self) -> impl Future<Output = Result<(), Self::Error>> {
36 (**self).close()
37 }
38}