pub struct Name(String);Expand description
A package name
Package names may contain the characters [a-zA-Z0-9\-._@+], but must not
start with [-.] (see alpm-package-name).
§Examples
use std::str::FromStr;
use alpm_types::{Error, Name};
// create Name from &str
assert_eq!(
Name::from_str("test-123@.foo_+"),
Ok(Name::new("test-123@.foo_+")?)
);
assert!(Name::from_str(".test").is_err());
// format as String
assert_eq!("foo", format!("{}", Name::new("foo")?));Tuple Fields§
§0: StringImplementations§
Source§impl Name
impl Name
Sourceconst SPECIAL_FIRST_CHARS: [char; 3]
const SPECIAL_FIRST_CHARS: [char; 3]
The subset of special characters that are allowed as first character of a Name.
Sourceconst NEVER_FIRST_CHAR: [char; 5]
const NEVER_FIRST_CHAR: [char; 5]
The set of characters allowed anywhere in a Name, except as first character.
Source§impl Name
impl Name
Sourcepub(crate) fn parse_name_followed_by_version<'a>(
delimiter_count: usize,
) -> impl Parser<&'a str, Self, ErrMode<ContextError>>
pub(crate) fn parse_name_followed_by_version<'a>( delimiter_count: usize, ) -> impl Parser<&'a str, Self, ErrMode<ContextError>>
Recognizes a Name as part of an InstalledPackage.
§Warning
This parser is designed specifically for the internal
InstalledPackage parser.
InstalledPackage is a very special use-case, as it uses
dashes (-) as delimiter. However, dashes are also valid characters in a Name.
As such, the Name parser must be aware of how many dashes are expected to be inside the
input string to parse.
This is a necessary, albeit cursed hack due to
InstalledPackage’s dash-based delimiter design.
In contrast to Name::parser, this function expects the final character to be a -,
which it does not consume.
§Errors
Returns an error if input does not begin with a valid alpm-package-name.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Name
impl<'de> Deserialize<'de> for Name
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Ord for Name
impl Ord for Name
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Name
impl PartialOrd for Name
impl Eq for Name
impl StructuralPartialEq for Name
Auto Trait Implementations§
impl Freeze for Name
impl RefUnwindSafe for Name
impl Send for Name
impl Sync for Name
impl Unpin for Name
impl UnsafeUnpin for Name
impl UnwindSafe for Name
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<U> ParserUntil for Uwhere
U: AlpmParser,
impl<U> ParserUntil for Uwhere
U: AlpmParser,
Source§fn parser_until<'a, P>(
delimiter: P,
) -> impl Parser<&'a str, U, ErrMode<ContextError>>
fn parser_until<'a, P>( delimiter: P, ) -> impl Parser<&'a str, U, ErrMode<ContextError>>
Returns a [Parser] that parses Self until the given delimiter parser
matches.
§Note
Does not consume the delimiter.
Source§fn parser_until_eof(input: &mut &str) -> Result<Self, ErrMode<ContextError>>
fn parser_until_eof(input: &mut &str) -> Result<Self, ErrMode<ContextError>>
Source§impl<U> ParserUntilInclusive for Uwhere
U: ParserUntil,
impl<U> ParserUntilInclusive for Uwhere
U: ParserUntil,
Source§fn parser_until_inclusive<'a, P>(
delimiter: P,
) -> impl Parser<&'a str, U, ErrMode<ContextError>>
fn parser_until_inclusive<'a, P>( delimiter: P, ) -> impl Parser<&'a str, U, ErrMode<ContextError>>
Returns a [Parser] that parses the whole input and consumes the given delimiter parser.
Delegates to ParserUntil::parser_until and consumes the delimiter.