pub fn load_or_create_key_pair(path: &str) -> Result<KeyPair, Box<dyn std::error::Error>> {
    let key_path = Path::new(path);

    if !key_path.exists() {
        info!("generating a new key pair");
        return Ok(create_new_key_pair(key_path)?);
    }

    if !key_path.is_dir() {
        return Ok(read_key_pair_from_file(key_path)?);
    }

    Err(Error::new(
        ErrorKind::InvalidInput,
        "Path to secret key is a directory.".to_string(),
    )
    .into())
}
/// Read the file with a secret key if it exists, generate a new key pair and write it to file if not.
Read the file with a secret key if it exists, generate a new key pair and write it to file if not.
Read the file with a secret key if it exists generate a new key pair and write it to file if not .
pub fn load_or_create_key_pair(path: &str) -> Result<KeyPair, Box<dyn std::error::Error>> {
    let key_path = Path::new(path);
    if !key_path.exists() {
        info!("generating a new key pair");
        return Ok(create_new_key_pair(key_path)?);
    }
    if !key_path.is_dir() {
        return Ok(read_key_pair_from_file(key_path)?);
    }
    Err(Error::new(
        ErrorKind::InvalidInput,
        "Path to secret key is a directory.".to_string(),
    )
    .into())
}
pub fn load_or_create_key_pair ( path : & str ) -> Result < KeyPair , Box < dyn std :: error :: Error > > { let key_path = Path :: new ( path ) ; if ! key_path . exists ( ) { info ! ( " " ) ; return Ok ( create_new_key_pair ( key_path ) ? ) ; } if ! key_path . is_dir ( ) { return Ok ( read_key_pair_from_file ( key_path ) ? ) ; } Err ( Error :: new ( ErrorKind :: InvalidInput , " " . to_string ( ) , ) . into ( ) ) }
Read the file with a secret key if it exists, generate a new key pair and write it to file if not.
Read the file with a secret key if it exists generate a new key pair and write it to file if not .
path
&str