erwanvivien / fast_qr

Ultra fast QRCode generation
https://fast-qr.com/
MIT License
208 stars 30 forks source link

Implement std::error::Error for ImageError #44

Closed orar closed 1 year ago

orar commented 1 year ago

Implement the std::error::Error trait for ImageError to enable easy error handling;

fn gen_qr_code(input: &str) -> Result<Vec<u8>, Box<dyn std::error::Error>> {
    let qr = QRBuilder::new(input).build()?;

    let img = ImageBuilder::default()
        .shape(Shape::RoundedSquare)
        .background_color([255, 255, 255, 0])
        .fit_width(600)
        .to_bytes(&qr)?;

     Ok(img)
}
erwanvivien commented 1 year ago

Hey thanks!