futures_stream_ext/throttle/interval/mod.rs
1// SPDX-FileCopyrightText: The futures-stream-ext authors
2// SPDX-License-Identifier: MPL-2.0
3
4use std::time::Duration;
5
6use crate::IntervalEdge;
7
8#[cfg(feature = "tokio")]
9mod tokio;
10#[cfg(feature = "tokio")]
11pub use self::tokio::IntervalThrottler;
12
13#[derive(Debug, Clone, PartialEq, Eq)]
14pub struct ThrottleIntervalConfig {
15 /// Throttling period
16 ///
17 /// The minimum interval between subsequent items that limits the
18 /// maximum frequency of the output stream.
19 pub period: Duration,
20
21 /// Interval edge gate
22 ///
23 /// Controls whether the pending item of the stream is yielded
24 /// immediately or after the interval has elapsed.
25 pub edge: IntervalEdge,
26}