pub async fn read_hosts(
    file_path: PathBuf,
) -> Result<HashSet<url::Host>, Box<dyn std::error::Error>> {
    use url::Host;

    let file = File::open(file_path).await?;
    let reader = BufReader::new(file);
    let mut list = reader.lines();
    let mut hosts = HashSet::new();
    while let Ok(Some(x)) = list.next_line().await {
        if let Ok(host) = Host::parse(&x) {
            hosts.insert(host);
        }
    }

    Ok(hosts)
}
/// Function to Read and return a list of hosts from a file.
/// Used from reading whitelist and blacklist.
Function to Read and return a list of hosts from a file.
Used from reading whitelist and blacklist.
Function to Read and return a list of hosts from a file . Used from reading whitelist and blacklist .
pub async fn read_hosts(
    file_path: PathBuf,
) -> Result<HashSet<url::Host>, Box<dyn std::error::Error>> {
    use url::Host;
    let file = File::open(file_path).await?;
    let reader = BufReader::new(file);
    let mut list = reader.lines();
    let mut hosts = HashSet::new();
    while let Ok(Some(x)) = list.next_line().await {
        if let Ok(host) = Host::parse(&x) {
            hosts.insert(host);
        }
    }
    Ok(hosts)
}
pub async fn read_hosts ( file_path : PathBuf , ) -> Result < HashSet < url :: Host > , Box < dyn std :: error :: Error > > { use url :: Host ; let file = File :: open ( file_path ) . await ? ; let reader = BufReader :: new ( file ) ; let mut list = reader . lines ( ) ; let mut hosts = HashSet :: new ( ) ; while let Ok ( Some ( x ) ) = list . next_line ( ) . await { if let Ok ( host ) = Host :: parse ( & x ) { hosts . insert ( host ) ; } } Ok ( hosts ) }
Function to Read and return a list of hosts from a file.
Function to Read and return a list of hosts from a file .
file_path
PathBuf
file_path
PathBuf