pub fn write_keypair_file<F: AsRef<Path>>(
    keypair: &Keypair,
    outfile: F,
) -> Result<String, Box<dyn error::Error>> {
    let outfile = outfile.as_ref();

    if let Some(outdir) = outfile.parent() {
        fs::create_dir_all(outdir)?;
    }

    let mut f = {
        #[cfg(not(unix))]
        {
            OpenOptions::new()
        }
        #[cfg(unix)]
        {
            use std::os::unix::fs::OpenOptionsExt;
            OpenOptions::new().mode(0o600)
        }
    }
    .write(true)
    .truncate(true)
    .create(true)
    .open(outfile)?;

    write_keypair(keypair, &mut f)
}
/// Writes a `Keypair` to a file with JSON-encoding
Writes a `Keypair` to a file with JSON-encoding
Writes a ` Keypair ` to a file with JSON - encoding
pub fn write_keypair_file<F: AsRef<Path>>(
    keypair: &Keypair,
    outfile: F,
) -> Result<String, Box<dyn error::Error>> {
    let outfile = outfile.as_ref();
    if let Some(outdir) = outfile.parent() {
        fs::create_dir_all(outdir)?;
    }
    let mut f = {
        #[cfg(not(unix))]
        {
            OpenOptions::new()
        }
        #[cfg(unix)]
        {
            use std::os::unix::fs::OpenOptionsExt;
            OpenOptions::new().mode(0o600)
        }
    }
    .write(true)
    .truncate(true)
    .create(true)
    .open(outfile)?;
    write_keypair(keypair, &mut f)
}
pub fn write_keypair_file < F : AsRef < Path > > ( keypair : & Keypair , outfile : F , ) -> Result < String , Box < dyn error :: Error > > { let outfile = outfile . as_ref ( ) ; if let Some ( outdir ) = outfile . parent ( ) { fs :: create_dir_all ( outdir ) ? ; } let mut f = { # [ cfg ( not ( unix ) ) ] { OpenOptions :: new ( ) } # [ cfg ( unix ) ] { use std :: os :: unix :: fs :: OpenOptionsExt ; OpenOptions :: new ( ) . mode ( 0o600 ) } } . write ( true ) . truncate ( true ) . create ( true ) . open ( outfile ) ? ; write_keypair ( keypair , & mut f ) }
Writes a `Keypair` to a file with JSON-encoding
Writes a ` Keypair ` to a file with JSON - encoding
keypair
&Keypair
outfile
F