INNER CODE UNIT · Rust
with_config
Trow-Registry/trow · src/lib.rs:114
pub fn with_config(
&mut self,
config_file: impl AsRef<str>,
) -> Result<&mut Self, TrowConfigError> {
let config_file = config_file.as_ref();
let config_str = fs::read_to_string(config_file)?;
let config = serde_yaml_ng::from_str::<ConfigFile>(&config_str)?;
self.config_file = config;
Ok(self)
}
pub fn with_user(&mut self, user: String, pass: &str) -> &mut Self {
let mut hash_config = argon2::Config::rfc9106();
hash_config.mem_cost = 4066;
hash_config.time_cost = 3;
let hash_encoded =
argon2::hash_encoded(pass.as_bytes(), Uuid::new_v4().as_bytes(), &hash_config)
.expect("Error hashing password");