m2 0.0.0

Set of Unix tools to work with m2dirs
Documentation
use std::{
    io::{self, copy, Read, Write},
    process::{Command, Stdio},
};

pub fn sign<R: Read + Send, W: Write>(mut mail: R, mut signature: W) -> io::Result<()> {
    let mut gpg = Command::new("gpg")
        .args(["--armor", "--detach-sign"])
        .stdin(Stdio::piped())
        .stdout(Stdio::piped())
        .spawn()?;

    {
        let mut stdin = gpg
            .stdin
            .take()
            .expect("gpg stdin was not captured. should not happen");
        copy(&mut mail, &mut stdin)?;
    }

    signature.write_all(&gpg.wait_with_output()?.stdout)?;

    Ok(())
}