fix: async for init_reader

This commit is contained in:
Elijah McMorris 2024-09-24 14:35:32 -07:00
parent 5fa50cf69f
commit 47cde83c7a
Signed by: NexVeridian
SSH key fingerprint: SHA256:bsA1SKZxuEcEVHAy3gY1HUeM5ykRJl0U0kQHQn0hMg8
4 changed files with 13 additions and 7 deletions

View file

@ -46,7 +46,9 @@ async fn main() -> Result<(), Error> {
sleep(Duration::from_secs(10)).await;
let pb = init_progress_bar::create_pb().await;
let reader = File_Format::new(get_wikidata_file_format().await)
.reader(get_wikidata_file_name().await)?;
.await
.reader(get_wikidata_file_name().await)
.await?;
fs::create_dir_all("data/temp").await?;
fs::remove_dir_all("data/temp").await?;

View file

@ -11,14 +11,14 @@ pub enum File_Format {
bz2,
}
impl File_Format {
pub fn new(file: &str) -> Self {
pub async fn new(file: &str) -> Self {
match file {
"json" => Self::json,
"bz2" => Self::bz2,
_ => panic!("Unknown file format"),
}
}
pub fn reader(self, file: &str) -> Result<Box<dyn BufRead>, Error> {
pub async fn reader(self, file: &str) -> Result<Box<dyn BufRead>, Error> {
let file = File::open(file)?;
match self {
File_Format::json => Ok(Box::new(BufReader::new(file))),