Add Arch
enum
This commit is contained in:
parent
935f10cb9d
commit
2247d2c572
48
src/arch.rs
Normal file
48
src/arch.rs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
use {
|
||||||
|
crate::Error,
|
||||||
|
serde::{Deserialize, Serialize},
|
||||||
|
std::{fmt, str},
|
||||||
|
};
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)]
|
||||||
|
pub enum Arch {
|
||||||
|
Any,
|
||||||
|
Arm,
|
||||||
|
Arm64,
|
||||||
|
RiscV64,
|
||||||
|
X86,
|
||||||
|
X86_64,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for Arch {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"{}",
|
||||||
|
match self {
|
||||||
|
Self::Any => "any",
|
||||||
|
Self::Arm => "armv7l",
|
||||||
|
Self::Arm64 => "aarch64",
|
||||||
|
Self::RiscV64 => "riscv64",
|
||||||
|
Self::X86 => "i486",
|
||||||
|
Self::X86_64 => "x86_64",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl str::FromStr for Arch {
|
||||||
|
type Err = Error;
|
||||||
|
|
||||||
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
|
match s {
|
||||||
|
"any" | "Any" | "noarch" => Ok(Self::Any),
|
||||||
|
"armv7l" | "ArmV7L" | "Armv7L" => Ok(Self::Arm),
|
||||||
|
"arm64" | "Arm64" | "aarch64" | "Aarch64" => Ok(Self::Arm64),
|
||||||
|
"RiscV64" | "riscv64" => Ok(Self::RiscV64),
|
||||||
|
"x86" | "X86" | "i486" => Ok(Self::X86),
|
||||||
|
"X86_64" | "Amd64" | "x86_64" | "amd64" => Ok(Self::X86_64),
|
||||||
|
_ => Err(Error::ParseArch),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,7 @@ use std::{
|
|||||||
pub enum Error {
|
pub enum Error {
|
||||||
FromUint,
|
FromUint,
|
||||||
Range,
|
Range,
|
||||||
|
ParseArch,
|
||||||
ParseInt,
|
ParseInt,
|
||||||
ParseGitRev,
|
ParseGitRev,
|
||||||
ParsePreRelease,
|
ParsePreRelease,
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use std::{fmt, str::FromStr};
|
use std::{fmt, str::FromStr};
|
||||||
|
|
||||||
|
mod arch;
|
||||||
mod error;
|
mod error;
|
||||||
mod extended;
|
mod extended;
|
||||||
mod gitrev;
|
mod gitrev;
|
||||||
@ -9,8 +10,8 @@ mod semver;
|
|||||||
mod simple;
|
mod simple;
|
||||||
|
|
||||||
pub use {
|
pub use {
|
||||||
error::Error, extended::Extended, gitrev::GitRev, prerelease::PreRelease, rapid::Rapid,
|
arch::Arch, error::Error, extended::Extended, gitrev::GitRev, prerelease::PreRelease,
|
||||||
semver::SemVer, simple::Simple,
|
rapid::Rapid, semver::SemVer, simple::Simple,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub static MAX_U12: u16 = 4096;
|
pub static MAX_U12: u16 = 4096;
|
||||||
|
Loading…
Reference in New Issue
Block a user