1#![no_std]
2#![cfg_attr(docsrs, feature(doc_cfg))]
3#![cfg_attr(docsrs, doc(cfg_hide(doc)))]
4
5use core::{
6 pin::Pin,
7 task::{Context, Poll},
8};
9
10use futures_sink::Sink;
11
12mod core_impls;
13#[cfg(feature = "futures-util")]
14mod futures_util_impls;
15#[cfg(feature = "std")]
16mod std_impls;
17
18#[must_use = "sinks do nothing unless polled"]
20pub trait FlushRoute<Route, Msg>: Sink<(Route, Msg)> {
21 fn poll_flush_route(
22 self: Pin<&mut Self>,
23 route: &Route,
24 cx: &mut Context<'_>,
25 ) -> Poll<Result<(), Self::Error>> {
26 let _ = route;
27 self.poll_flush(cx)
28 }
29
30 fn poll_close_route(
31 self: Pin<&mut Self>,
32 route: &Route,
33 cx: &mut Context<'_>,
34 ) -> Poll<Result<(), Self::Error>> {
35 self.poll_flush_route(route, cx)
36 }
37}
38
39#[must_use = "sinks do nothing unless polled"]
41pub trait ReadyRoute<Route, Msg>: FlushRoute<Route, Msg> {
42 fn poll_ready_route(
43 self: Pin<&mut Self>,
44 route: &Route,
45 cx: &mut Context<'_>,
46 ) -> Poll<Result<(), Self::Error>> {
47 let _ = route;
48 self.poll_ready(cx)
49 }
50}
51
52#[must_use = "sinks do nothing unless polled"]
54pub trait ReadySome<Route, Msg>: FlushRoute<Route, Msg> {
55 fn poll_ready_some(
56 self: Pin<&mut Self>,
57 cx: &mut Context<'_>,
58 ) -> Poll<Result<Route, Self::Error>>;
59}