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

Improve the fetcher revision API #193

Merged
merged 3 commits into from
Dec 14, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Narrow revision parsing error type
MOZGIII committed Dec 8, 2023
commit 13828a7bd528a2b09746dabd174a102a332ddda4
12 changes: 4 additions & 8 deletions chromiumoxide_fetcher/src/revision.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use std::fmt;

use crate::FetcherError;
use std::{fmt, num::ParseIntError};

/// A [`Revision`] represents a version of chromium.
///
@@ -23,17 +21,15 @@ impl From<Revision> for u32 {
}

impl std::str::FromStr for Revision {
type Err = FetcherError;
type Err = ParseIntError;

fn from_str(s: &str) -> Result<Self, Self::Err> {
s.parse::<u32>()
.map_err(|e| FetcherError::InvalidRevision(e))
.map(|v| Self(v))
s.parse::<u32>().map(|v| Self(v))
}
}

impl TryFrom<String> for Revision {
type Error = FetcherError;
type Error = ParseIntError;

fn try_from(value: String) -> Result<Self, Self::Error> {
value.parse()