fix: implement Write trait for digest engines

This commit is contained in:
Andrew Phillips (aider)
2025-05-12 20:36:15 -03:00
parent f748fdd0f3
commit c7533890c8
4 changed files with 71 additions and 13 deletions

View File

@@ -14,11 +14,31 @@ impl DigestEngineNone {
impl DigestEngine for DigestEngineNone {
fn create(&self) -> Result<Box<dyn Write>> {
Ok(Box::new(Self::new()))
Ok(Box::new(DummyWriter::new()))
}
fn finalize(&mut self) -> io::Result<String> {
Ok("none".to_string())
}
fn update(&mut self, _data: &[u8]) {}
}
// Dummy writer that implements Write for the none digest engine
struct DummyWriter;
impl DummyWriter {
fn new() -> Self {
DummyWriter
}
}
impl Write for DummyWriter {
fn write(&mut self, _buf: &[u8]) -> io::Result<usize> {
Ok(0)
}
fn flush(&mut self) -> io::Result<()> {
Ok(())
}
}