feat: take Path in FileBasedCertVerifier::init

This commit is contained in:
DarkCat09 2024-08-09 12:41:23 +04:00
parent 32895e5b65
commit 3359c3c9fd
Signed by: DarkCat09
GPG key ID: 0A26CD5B3345D6E3

View file

@ -1,4 +1,4 @@
use std::{borrow::Cow, io::Write, os::fd::AsFd, sync::Mutex};
use std::{borrow::Cow, io::Write, os::fd::AsFd, path::Path, sync::Mutex};
use dashmap::DashMap;
use tokio::io::AsyncBufReadExt;
@ -18,11 +18,11 @@ pub struct FileBasedCertVerifier {
}
impl FileBasedCertVerifier {
pub async fn init(path: &str) -> Result<Self, LibError> {
pub async fn init(path: impl AsRef<Path>) -> Result<Self, LibError> {
let map = DashMap::new();
if tokio::fs::try_exists(path).await? {
let mut f = tokio::fs::OpenOptions::new().read(true).open(path).await?;
if tokio::fs::try_exists(&path).await? {
let mut f = tokio::fs::OpenOptions::new().read(true).open(&path).await?;
let mut reader = tokio::io::BufReader::new(&mut f);