use core::fmt::{Debug, Formatter, Result as FmtResult}; use core::pin::Pin; use futures_core::task::{Context, Poll}; use futures_sink::Sink; use pin_project_lite::pin_project;
pin_project! { /// Sink that clones incoming items and forwards them to two sinks at the same time. /// /// Backpressure from any downstream sink propagates up, which means that this sink /// can only process items as fast as its _slowest_ downstream sink. #[must_use = "sinks do nothing unless polled"] pubstruct Fanout<Si1, Si2> { #[pin]
sink1: Si1, #[pin]
sink2: Si2
}
}
/// Get a shared reference to the inner sinks. pubfn get_ref(&self) -> (&Si1, &Si2) {
(&self.sink1, &self.sink2)
}
/// Get a mutable reference to the inner sinks. pubfn get_mut(&mutself) -> (&mut Si1, & style='color:red'>mut Si2) {
(&mutself.sink1, &mutself.sink2)
}
/// Get a pinned mutable reference to the inner sinks. pubfn get_pin_mut(self: Pin<&mutSelf>) -> (Pin<&mut Si1>, Pin<&mut Si2>) { let this = self.project();
(this.sink1, this.sink2)
}
/// Consumes this combinator, returning the underlying sinks. /// /// Note that this may discard intermediate state of this combinator, /// so care should be taken to avoid losing resources when this is called. pubfn into_inner(self) -> (Si1, Si2) {
(self.sink1, self.sink2)
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.