pub struct Packager { /* private fields */ }Expand description
A packager of a package
A Packager is represented by a User ID (e.g. "Foobar McFooFace <foobar@mcfooface.org>").
Internally this struct wraps a String for the name and an EmailAddress for a valid email
address.
§Examples
use std::str::FromStr;
use alpm_types::{Error, Packager};
// create Packager from &str
let packager = Packager::from_str("Foobar McFooface <foobar@mcfooface.org>")?;
// get name
assert_eq!("Foobar McFooface", packager.name());
// get email
assert_eq!("foobar@mcfooface.org", packager.email().to_string());
// get email domain
assert_eq!("mcfooface.org", packager.email().domain());
// format as String
assert_eq!(
"Foobar McFooface <foobar@mcfooface.org>",
format!("{}", packager)
);Implementations§
Source§impl Packager
impl Packager
Sourcepub fn new(name: String, email: EmailAddress) -> Packager
pub fn new(name: String, email: EmailAddress) -> Packager
Create a new Packager
Sourcepub fn email(&self) -> &EmailAddress
pub fn email(&self) -> &EmailAddress
Return the email of the Packager
Sourcepub fn parser(input: &mut &str) -> ModalResult<Self>
pub fn parser(input: &mut &str) -> ModalResult<Self>
Parses a Packager from a string slice.
Consumes all of its input.
§Examples
See Self::from_str for code examples.
§Errors
Returns an error if input does not represent a valid Packager.
Trait Implementations§
impl Eq for Packager
impl StructuralPartialEq for Packager
Auto Trait Implementations§
impl Freeze for Packager
impl RefUnwindSafe for Packager
impl Send for Packager
impl Sync for Packager
impl Unpin for Packager
impl UnwindSafe for Packager
Blanket Implementations§
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
Mutably borrows from an owned value. Read more