TaKO8Ki / frum

A little bit fast and modern Ruby version manager written in Rust
MIT License
636 stars 15 forks source link

parse index with csv #106

Open pynixwang opened 3 years ago

pynixwang commented 3 years ago
use serde::Deserialize;

#[derive(Debug, Deserialize)]
struct Version {
    name: String,
    url: String,
    sha256: String
}

let resp = reqwest::blocking::get("https://cache.ruby-lang.org/pub/ruby/index.txt")?;

let mut rdr = csv::ReaderBuilder::new()
    .delimiter(b'\t')
    .from_reader(resp);
for result in rdr.deserialize() {
    let version: Version = result?;
    println!("{:?}", version);
}
pynixwang commented 3 years ago

much clean than regexp