intermodal/src/step.rs
Casey Rodarmor 0033e8381f
Test imdl torrent verify output
- Test all individual `FileError` variants
- Test terminal colors
- Test multiple and single file torrents

type: testing
2020-04-07 19:01:27 -07:00

35 lines
659 B
Rust

use crate::common::*;
pub(crate) trait Step {
fn print(&self, env: &mut Env) -> Result<(), Error> {
let style = env.err().style();
let dim = style.dim();
let message = style.message();
err!(
env,
"{}[{}/{}]{} ",
dim.prefix(),
self.n(),
Self::total(),
dim.suffix()
)?;
err!(env, "{} {}", self.symbol(), message.prefix())?;
self.write_message(env.err_mut()).context(error::Stderr)?;
errln!(env, "{}", message.suffix())?;
Ok(())
}
fn n(&self) -> usize;
fn total() -> usize;
fn write_message(&self, write: &mut dyn Write) -> io::Result<()>;
fn symbol(&self) -> &str;
}