Activity

frazeb09

What is new

naw my app is usable.

i added location search mechanism.

pub fn get_location(path: PathBuf, query: &str, ) -> Result<Option<Location>, Box<dyn std:![error](https://images.weserv.nl/?url=https%3A%2F%2Femoji.slack-edge.com%2FT09V59WQY1E%2Ferror%2F85050940284426fe.gif&w=30&h=30&fit=contain&n=-1):Error>> {
    let mut rdr = csv::ReaderBuilder::new().from_path(path)?;
    for result in rdr.deserialize() {
        let record: Record = result?;
        if record.city == query {
            return Ok(Some(Location {
                latitude: record.lat,
                longitude: record.lng,
            }));
        }
    }

    Ok(None)
}

Changelog

Attachment
0
frazeb09

What is new

i found way to check to find lokacion of citi

Made function that downloads csv file with names and lokacions of citis

and this is this somthing
and this is this somthing

pub async  fn downloading_data(path:PathBuf) -> Result<(),String> {
    //dbg!(&path);
    let reqs = reqwest::Client::new().get("https://raw.githubusercontent.com/Detalexpl/TuiWeather/refs/heads/master/worldcities.csv")
        .send().await.map_err(|e| e.to_string())?.text().await.map_err(|e| e.to_string())?;

    create_dir(&path).await.map_err(|e| e.to_string())?;
    let mut out = File::create(path.join("cities.csv")).map_err(|e| e.to_string())?;
    out.write_all(reqs.as_bytes()).map_err(|e| e.to_string())?;
    
    Ok(())
}

parsing json is naw in separate file

Changelog

Attachment
0