mirror of
https://github.com/DNSCrypt/encrypted-dns-server.git
synced 2024-05-20 02:56:05 +02:00
Use impl AsRef<...>
This commit is contained in:
parent
73a176d555
commit
8a4a413f65
|
@ -28,7 +28,7 @@ impl BlackList {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn load<P: AsRef<Path>>(path: P) -> Result<Self, Error> {
|
||||
pub fn load(path: impl AsRef<Path>) -> Result<Self, Error> {
|
||||
let mut map = FxHashMap::default();
|
||||
let fp = BufReader::new(File::open(path)?);
|
||||
for (line_nb, line) in fp.lines().enumerate() {
|
||||
|
|
|
@ -98,7 +98,7 @@ impl Config {
|
|||
Ok(config)
|
||||
}
|
||||
|
||||
pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Config, Error> {
|
||||
pub fn from_path(path: impl AsRef<Path>) -> Result<Config, Error> {
|
||||
let toml = fs::read_to_string(path)?;
|
||||
Config::from_string(&toml)
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ impl State {
|
|||
State::with_key_pair(provider_kp, key_cache_capacity)
|
||||
}
|
||||
|
||||
pub async fn async_save<P: AsRef<Path>>(&self, path: P) -> Result<(), Error> {
|
||||
pub async fn async_save(&self, path: impl AsRef<Path>) -> Result<(), Error> {
|
||||
let path_tmp = path.as_ref().with_extension("tmp");
|
||||
let mut fpb = tokio::fs::OpenOptions::new();
|
||||
let fpb = fpb.create(true).write(true);
|
||||
|
@ -140,7 +140,7 @@ impl State {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn from_file<P: AsRef<Path>>(path: P, key_cache_capacity: usize) -> Result<Self, Error> {
|
||||
pub fn from_file(path: impl AsRef<Path>, key_cache_capacity: usize) -> Result<Self, Error> {
|
||||
let state_bin = fs::read(path)?;
|
||||
let mut state: State = toml::from_slice(&state_bin)?;
|
||||
for params_set in &mut state.dnscrypt_encryption_params_set {
|
||||
|
|
Loading…
Reference in New Issue