Skip to content

Commit

Permalink
Renames Keystore::new to generate
Browse files Browse the repository at this point in the history
  • Loading branch information
ultimaweapon committed Apr 22, 2024
1 parent d3c0623 commit 608b75b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/key/store/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ impl Keystore for DefaultStore {
KeyList {}
}

fn new(self: Arc<Self>) -> Result<Key, Box<dyn Error>> {
fn generate(self: Arc<Self>) -> Result<Key, Box<dyn Error>> {
// Generate a new key.
let mut key = Zeroizing::new([0u8; 16]);

if let Err(e) = getrandom(key.deref_mut()) {
return Err(Box::new(NewError::GenerateKeyFailed(e)));
return Err(Box::new(GenerateError::GenerateKeyFailed(e)));
}

// Get a key check value.
Expand Down Expand Up @@ -70,7 +70,7 @@ impl Iterator for KeyList {

/// Represents an error when [`DefaultStore::new()`] fails.
#[derive(Debug, Error)]
enum NewError {
enum GenerateError {
#[error("couldn't generate a new key")]
GenerateKeyFailed(#[source] getrandom::Error),
}
2 changes: 1 addition & 1 deletion src/key/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ pub trait Keystore {
where
Self: Sized;

fn new(self: Arc<Self>) -> Result<Key, Box<dyn Error>>;
fn generate(self: Arc<Self>) -> Result<Key, Box<dyn Error>>;
}

0 comments on commit 608b75b

Please sign in to comment.