bctx-forge 0.1.7

bctx-forge — OS execution substrate, signal capture, BPE tokenizer, SQLite tracker
Documentation
/// Line-by-line output filter with backpressure support.
pub struct OutputStream {
    lines: Vec<String>,
    max_lines: usize,
}

impl OutputStream {
    pub fn new(max_lines: usize) -> Self {
        Self {
            lines: Vec::new(),
            max_lines,
        }
    }

    pub fn feed(&mut self, line: impl Into<String>) -> bool {
        if self.lines.len() < self.max_lines {
            self.lines.push(line.into());
            true
        } else {
            false
        }
    }

    pub fn finish(self) -> Vec<String> {
        self.lines
    }
}