pub fn new<P: AsRef<Path>>(path: P, force_overwrite: bool) -> Result<Self> {
        let mut f = fs::OpenOptions::new()
            .read(true)
            // Open in write mode, in case we need to create the file.
            .write(true)
            // We'll always create it, if it doesn't already exist.
            .create(true)
            // Only truncate existing data if `force_overwrite` is set.
            .truncate(force_overwrite)
            .open(path.as_ref())?;

        Ok(DiskKeyStore {
            path: path.as_ref().to_path_buf(),
            inner: if f.metadata()?.len() == 0 {
                // If the file was of zero length, just remove it. Most likely
                // we created it, but if this key store doens't end up being
                // persisted we don't want to leave an orphaned file around.
                fs::remove_file(path.as_ref())?;
                KeyStore::new()?
            } else {
                KeyStore::load_read(&mut f)?
            },
        })
    }
/// Construct a new DiskKeyStore instance. If the given path already exists,
/// a pre-existing key store will be loaded from it. Otherwise, a brand new
/// key store will be initialized.
///
/// It is up to the caller to check for the latter case, and to add a key
/// as appropriate.
///
/// If `force_overwrite` is set to `true`, then a fresh instance is created,
/// even if a previous one already existed.
Construct a new DiskKeyStore instance. If the given path already exists,
a pre-existing key store will be loaded from it. Otherwise, a brand new
key store will be initialized.

It is up to the caller to check for the latter case, and to add a key
as appropriate.

If `force_overwrite` is set to `true`, then a fresh instance is created,
even if a previous one already existed.
Construct a new DiskKeyStore instance . If the given path already exists a pre - existing key store will be loaded from it . Otherwise a brand new key store will be initialized . It is up to the caller to check for the latter case and to add a key as appropriate . If ` force_overwrite ` is set to ` true ` then a fresh instance is created even if a previous one already existed .
pub fn new<P: AsRef<Path>>(path: P, force_overwrite: bool) -> Result<Self> {
        let mut f = fs::OpenOptions::new()
            .read(true)
            // Open in write mode, in case we need to create the file.
            .write(true)
            // We'll always create it, if it doesn't already exist.
            .create(true)
            // Only truncate existing data if `force_overwrite` is set.
            .truncate(force_overwrite)
            .open(path.as_ref())?;
        Ok(DiskKeyStore {
            path: path.as_ref().to_path_buf(),
            inner: if f.metadata()?.len() == 0 {
                // If the file was of zero length, just remove it. Most likely
                // we created it, but if this key store doens't end up being
                // persisted we don't want to leave an orphaned file around.
                fs::remove_file(path.as_ref())?;
                KeyStore::new()?
            } else {
                KeyStore::load_read(&mut f)?
            },
        })
    }
pub fn new < P : AsRef < Path > > ( path : P , force_overwrite : bool ) -> Result < Self > { let mut f = fs :: OpenOptions :: new ( ) . read ( true ) // Open in write mode, in case we need to create the file. . write ( true ) // We'll always create it, if it doesn't already exist. . create ( true ) // Only truncate existing data if `force_overwrite` is set. . truncate ( force_overwrite ) . open ( path . as_ref ( ) ) ? ; Ok ( DiskKeyStore { path : path . as_ref ( ) . to_path_buf ( ) , inner : if f . metadata ( ) ? . len ( ) == 0 { // If the file was of zero length, just remove it. Most likely // we created it, but if this key store doens't end up being // persisted we don't want to leave an orphaned file around. fs :: remove_file ( path . as_ref ( ) ) ? ; KeyStore :: new ( ) ? } else { KeyStore :: load_read ( & mut f ) ? } , } ) }
Construct a new DiskKeyStore instance.
Construct a new DiskKeyStore instance .
path
P
force_overwrite
bool
path
P
force_overwrite
bool