diff --git a/chromiumoxide_fetcher/src/revision.rs b/chromiumoxide_fetcher/src/revision.rs index 394d2718..8768fc90 100644 --- a/chromiumoxide_fetcher/src/revision.rs +++ b/chromiumoxide_fetcher/src/revision.rs @@ -1,6 +1,4 @@ -use std::fmt; - -use crate::FetcherError; +use std::{fmt, num::ParseIntError}; /// A [`Revision`] represents a version of chromium. /// @@ -16,14 +14,25 @@ impl From for Revision { } } +impl From for u32 { + fn from(value: Revision) -> Self { + value.0 + } +} + +impl std::str::FromStr for Revision { + type Err = ParseIntError; + + fn from_str(s: &str) -> Result { + s.parse::().map(|v| Self(v)) + } +} + impl TryFrom for Revision { - type Error = FetcherError; + type Error = ParseIntError; fn try_from(value: String) -> Result { - value - .parse::() - .map_err(|e| FetcherError::InvalidRevision(e)) - .map(|v| Self(v)) + value.parse() } }