Skip to main content

create_generated

Function create_generated 

Source
pub fn create_generated(
    path: impl AsRef<Path>,
    config: MnemoConfig,
    prepare: &mut dyn FnMut(&mut Mnemo) -> Result<()>,
    persist: &mut Persist<'_>,
) -> Result<Zeroizing<[u8; 32]>>
Expand description

Create a brain at path under a freshly generated key (the keys note, section 1). In this order, so there’s never a brain at path whose key is only in memory:

  1. the key is drawn, and the brain is created under a temp name next to path with the raw-key parameters;
  2. prepare runs on it (the CLI writes its manifest), and it’s closed;
  3. persist keeps the key, given the brain’s salt (a key store’s store_and_check, or a new key file);
  4. the temp file takes path’s name.

path must not exist. Dead init temps next to it are removed first. On an error the temp file is removed.