// Load a keypair from the specified path. It only returns a Keypair if all
// the following conditions are met:
//
//  * the file at the specified path exists
//  * the size of the file is exactly 64 bytes
//  * no io errors occured while reading from the file
Load a keypair from the specified path. It only returns a Keypair if all
the following conditions are met.

the file at the specified path exists
the size of the file is exactly 64 bytes
no io errors occured while reading from the file
Load a keypair from the specified path . It only returns a Keypair if all the following conditions are met . the file at the specified path exists the size of the file is exactly 64 bytes no io errors occured while reading from the file
fn load_ed25519(keypair_path: &str) -> Result<identity::ed25519::Keypair, Box<dyn error::Error>> {
    let mut keypair_file = fs::File::open(keypair_path)?;
    let keypair_metadata = fs::metadata(keypair_path)?;
    if keypair_metadata.len() == 64 {
        let mut buffer = vec![0; 64];
        keypair_file.read_exact(&mut buffer)?;
        return Ok(identity::ed25519::Keypair::decode(&mut buffer)?);
    }
    Err(Box::new(io::Error::from(io::ErrorKind::InvalidData)))
}
fn load_ed25519 ( keypair_path : & str ) -> Result < identity :: ed25519 :: Keypair , Box < dyn error :: Error > > { let mut keypair_file = fs :: File :: open ( keypair_path ) ? ; let keypair_metadata = fs :: metadata ( keypair_path ) ? ; if keypair_metadata . len ( ) == 64 { let mut buffer = vec ! [ 0 64 ] ; keypair_file . read_exact ( & mut buffer ) ? ; return Ok ( identity :: ed25519 :: Keypair :: decode ( & mut buffer ) ? ) ; } Err ( Box :: new ( io :: Error :: from ( io :: ErrorKind :: InvalidData ) ) ) }
Load a keypair from the specified path.
Load a keypair from the specified path .
keypair_path
&str