Parser::append

This commit is contained in:
KitsuneCafe 2024-02-05 05:04:54 -05:00
parent c0ae1a2229
commit 7839db8b06

View file

@ -37,6 +37,10 @@ impl<'a> Parser<'a> {
pub fn push<P: AsParse>(&mut self, parser: &'a mut P) {
self.steps.push(parser.as_parse_mut());
}
pub fn append(&mut self, parsers: &mut Vec<&'a mut dyn Parse>) {
self.steps.append(parsers);
}
}
impl<'a> Parse for Parser<'a> {
@ -141,3 +145,27 @@ impl Roxy {
Self::mkdir_and_open(&output).and_then(|mut f| f.write_all(&buf))
}
}
#[cfg(test)]
mod tests {
use super::{Parse, Parser};
struct TestParser;
impl TestParser {
pub fn new() -> Self {
Self
}
}
impl Parse for TestParser {
fn parse(
&mut self,
path: &str,
src: &[u8],
dst: &mut Vec<u8>,
) -> Result<(), crate::error::Error> {
Ok(())
}
}
}