Skip to main content

edfsm_machine/
output.rs

1use alloc::vec::Vec;
2use edfsm::{Drain, Init};
3
4#[derive(Debug)]
5pub struct OutputBuffer<A>(pub Vec<A>);
6
7impl<A> OutputBuffer<A> {
8    pub fn push(&mut self, item: A) {
9        self.0.push(item);
10    }
11}
12
13impl<A> Default for OutputBuffer<A> {
14    fn default() -> Self {
15        Self(Vec::new())
16    }
17}
18
19impl<A> Drain for OutputBuffer<A>
20where
21    A: Send,
22{
23    type Item = A;
24
25    fn drain_all(&mut self) -> impl Iterator<Item = Self::Item> {
26        self.0.drain(0..)
27    }
28}
29
30impl<S, A> Init<S> for OutputBuffer<A> {
31    fn init(&mut self, _: &S) {}
32}