mirror of
https://github.com/rustic-rs/rustic.git
synced 2025-10-26 11:18:51 +00:00
21 lines
620 B
Rust
21 lines
620 B
Rust
//! `key` example
|
|
use rustic_core::{KeyOpts, Repository, RepositoryOptions};
|
|
use simplelog::{Config, LevelFilter, SimpleLogger};
|
|
use std::error::Error;
|
|
|
|
fn main() -> Result<(), Box<dyn Error>> {
|
|
// Display info logs
|
|
let _ = SimpleLogger::init(LevelFilter::Info, Config::default());
|
|
|
|
// Open repository
|
|
let repo_opts = RepositoryOptions::default()
|
|
.repository("/tmp/repo")
|
|
.password("test");
|
|
let repo = Repository::new(&repo_opts)?.open()?;
|
|
|
|
// Add a new key with the given password
|
|
let key_opts = KeyOpts::default();
|
|
repo.add_key("new_password", &key_opts)?;
|
|
Ok(())
|
|
}
|