dfir_pipes/pull/
repeat.rs1use crate::No;
2use crate::pull::{FusedPull, Pull, PullStep, fuse_self};
3
4#[must_use = "`Pull`s do nothing unless polled"]
6#[derive(Clone, Debug, Default)]
7pub struct Repeat<Item> {
8 item: Item,
9}
10
11impl<Item> Repeat<Item>
12where
13 Self: Pull,
14{
15 pub(crate) const fn new(item: Item) -> Self {
16 Self { item }
17 }
18}
19
20impl<Item> Unpin for Repeat<Item> {}
21
22impl<Item> Pull for Repeat<Item>
23where
24 Item: Clone,
25{
26 type Ctx<'ctx> = ();
27
28 type Item = Item;
29 type Meta = ();
30 type CanPend = No;
31 type CanEnd = No;
32
33 fn pull(
34 self: core::pin::Pin<&mut Self>,
35 _ctx: &mut Self::Ctx<'_>,
36 ) -> PullStep<Self::Item, Self::Meta, Self::CanPend, Self::CanEnd> {
37 PullStep::Ready(self.item.clone(), ())
38 }
39
40 fn size_hint(&self) -> (usize, Option<usize>) {
41 (usize::MAX, None)
42 }
43
44 fuse_self!();
45}
46
47impl<Item> FusedPull for Repeat<Item> where Item: Clone {}