Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Oct 29, 2023

Conversation

orar
Copy link

@orar orar commented Oct 29, 2023

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 erwanvivien merged commit a7aa55a into erwanvivien:master Oct 29, 2023
4 checks passed
@erwanvivien
Copy link
Owner

Hey thanks!

erwanvivien added a commit that referenced this pull request Oct 30, 2023
erwanvivien added a commit that referenced this pull request Oct 30, 2023
erwanvivien added a commit that referenced this pull request Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants