arch_pkg_text/desc/
field.rsuse derive_more::{AsRef, Deref};
use strum::{AsRefStr, Display, EnumString, IntoStaticStr};
#[derive(Debug, Clone, Copy, Eq, PartialEq)] #[derive(AsRef, Deref, derive_more::Display)] #[display("%{_0}%")]
pub struct Field<Name>(Name);
impl<Name> Field<Name> {
pub const fn name(&self) -> &'_ Name {
&self.0
}
pub fn into_name(self) -> Name {
self.0
}
}
pub type RawField<'a> = Field<&'a str>;
impl<'a> RawField<'a> {
pub const fn name_str(&self) -> &'a str {
self.name()
}
}
pub type ParsedField = Field<FieldName>;
impl ParsedField {
pub const fn new(name: FieldName) -> Self {
Field(name)
}
pub fn name_str(&self) -> &'static str {
self.name().into()
}
}
impl From<FieldName> for ParsedField {
fn from(value: FieldName) -> Self {
ParsedField::new(value)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(AsRefStr, Display, EnumString, IntoStaticStr)] #[strum(use_phf)]
pub enum FieldName {
#[strum(serialize = "FILENAME")]
FileName,
#[strum(serialize = "NAME")]
Name,
#[strum(serialize = "BASE")]
Base,
#[strum(serialize = "VERSION")]
Version,
#[strum(serialize = "DESC")]
Description,
#[strum(serialize = "GROUPS")]
Groups,
#[strum(serialize = "CSIZE")]
CompressedSize,
#[strum(serialize = "ISIZE")]
InstalledSize,
#[strum(serialize = "MD5SUM")]
Md5Checksum,
#[strum(serialize = "SHA256SUM")]
Sha256Checksum,
#[strum(serialize = "PGPSIG")]
PgpSignature,
#[strum(serialize = "URL")]
Url,
#[strum(serialize = "LICENSE")]
License,
#[strum(serialize = "ARCH")]
Architecture,
#[strum(serialize = "BUILDDATE")]
BuildDate,
#[strum(serialize = "PACKAGER")]
Packager,
#[strum(serialize = "DEPENDS")]
Dependencies,
#[strum(serialize = "MAKEDEPENDS")]
MakeDependencies,
#[strum(serialize = "CHECKDEPENDS")]
CheckDependencies,
#[strum(serialize = "OPTDEPENDS")]
OptionalDependencies,
#[strum(serialize = "PROVIDES")]
Provides,
#[strum(serialize = "CONFLICTS")]
Conflicts,
#[strum(serialize = "REPLACES")]
Replaces,
}
mod parse;
pub use parse::*;