pub struct Stream<T> {
pub metrics: Arc<StreamMetrics>,
/* private fields */
}Expand description
Bounded async stream with a declared backpressure policy.
Clone-able handle — producer and consumer hold the same Arc.
Fields§
§metrics: Arc<StreamMetrics>Implementations§
Source§impl<T: Send + 'static> Stream<T>
impl<T: Send + 'static> Stream<T>
Sourcepub fn new(capacity: usize, annotation: BackpressureAnnotation) -> Self
pub fn new(capacity: usize, annotation: BackpressureAnnotation) -> Self
Build a stream whose policy is DropOldest / PauseUpstream /
Fail. Use Stream::with_degrader for DegradeQuality.
Sourcepub fn with_degrader(
capacity: usize,
annotation: BackpressureAnnotation,
degrader: DegradationFn<T>,
) -> Self
pub fn with_degrader( capacity: usize, annotation: BackpressureAnnotation, degrader: DegradationFn<T>, ) -> Self
Build a DegradeQuality stream with the mandatory degrader.
pub fn policy(&self) -> BackpressurePolicy
pub fn annotation(&self) -> &BackpressureAnnotation
Sourcepub async fn push(&self, item: T) -> Result<(), StreamError>
pub async fn push(&self, item: T) -> Result<(), StreamError>
Push an item. Dispatches to the declared policy.
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Stream<T>
impl<T> !UnwindSafe for Stream<T>
impl<T> Freeze for Stream<T>
impl<T> Send for Stream<T>where
T: Send,
impl<T> Sync for Stream<T>where
T: Send,
impl<T> Unpin for Stream<T>
impl<T> UnsafeUnpin for Stream<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.