pub struct InstalledPackage {
name: Name,
version: FullVersion,
architecture: Architecture,
}
Expand description
Information on an installed package in an environment
Tracks the Name
, FullVersion
and an Architecture
of a package in an environment.
§Examples
use std::str::FromStr;
use alpm_types::{Architecture, FullVersion, InstalledPackage, Name};
assert_eq!(
InstalledPackage::from_str("foo-bar-1:1.0.0-1-any")?,
InstalledPackage::new(
Name::new("foo-bar")?,
FullVersion::from_str("1:1.0.0-1")?,
Architecture::Any
)
);
assert_eq!(
InstalledPackage::from_str("foo-bar-1.0.0-1-any")?,
InstalledPackage::new(
Name::new("foo-bar")?,
FullVersion::from_str("1.0.0-1")?,
Architecture::Any
)
);
Fields§
§name: Name
§version: FullVersion
§architecture: Architecture
Implementations§
Source§impl InstalledPackage
impl InstalledPackage
Sourcepub fn new(name: Name, version: FullVersion, architecture: Architecture) -> Self
pub fn new(name: Name, version: FullVersion, architecture: Architecture) -> Self
Creates a new InstalledPackage
.
§Examples
use std::str::FromStr;
use alpm_types::InstalledPackage;
assert_eq!(
"example-1:1.0.0-1-x86_64",
InstalledPackage::new("example".parse()?, "1:1.0.0-1".parse()?, "x86_64".parse()?)
.to_string()
);
Sourcepub fn version(&self) -> &FullVersion
pub fn version(&self) -> &FullVersion
Returns a reference to the FullVersion
.
§Examples
use std::str::FromStr;
use alpm_types::{FullVersion, InstalledPackage};
let file_name =
InstalledPackage::new("example".parse()?, "1:1.0.0-1".parse()?, "x86_64".parse()?);
assert_eq!(file_name.version(), &FullVersion::from_str("1:1.0.0-1")?);
Sourcepub fn architecture(&self) -> Architecture
pub fn architecture(&self) -> Architecture
Returns the Architecture
.
§Examples
use std::str::FromStr;
use alpm_types::{Architecture, InstalledPackage};
let file_name =
InstalledPackage::new("example".parse()?, "1:1.0.0-1".parse()?, "x86_64".parse()?);
assert_eq!(file_name.architecture(), Architecture::X86_64);
Sourcepub fn parser(input: &mut &str) -> ModalResult<Self>
pub fn parser(input: &mut &str) -> ModalResult<Self>
Recognizes an InstalledPackage
in a string slice.
Relies on [winnow
] to parse input
and recognize the Name
, FullVersion
, and
Architecture
components.
§Errors
Returns an error if
- the
Name
component can not be recognized, - the
FullVersion
component can not be recognized, - or the
Architecture
component can not be recognized.
§Examples
use alpm_types::InstalledPackage;
use winnow::Parser;
let name = "example-package-1:1.0.0-1-x86_64";
assert_eq!(name, InstalledPackage::parser.parse(name)?.to_string());
Trait Implementations§
Source§impl Clone for InstalledPackage
impl Clone for InstalledPackage
Source§fn clone(&self) -> InstalledPackage
fn clone(&self) -> InstalledPackage
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for InstalledPackage
impl Debug for InstalledPackage
Source§impl Display for InstalledPackage
impl Display for InstalledPackage
Source§impl From<PackageFileName> for InstalledPackage
impl From<PackageFileName> for InstalledPackage
Source§fn from(value: PackageFileName) -> Self
fn from(value: PackageFileName) -> Self
Creates a InstalledPackage
from a PackageFileName
.
Source§impl FromStr for InstalledPackage
impl FromStr for InstalledPackage
Source§fn from_str(s: &str) -> Result<InstalledPackage, Self::Err>
fn from_str(s: &str) -> Result<InstalledPackage, Self::Err>
Creates an InstalledPackage
from a string slice.
Delegates to InstalledPackage::parser
.
§Errors
Returns an error if InstalledPackage::parser
fails.
§Examples
use std::str::FromStr;
use alpm_types::InstalledPackage;
let filename = "example-package-1:1.0.0-1-x86_64";
assert_eq!(filename, InstalledPackage::from_str(filename)?.to_string());
Source§impl Ord for InstalledPackage
impl Ord for InstalledPackage
Source§fn cmp(&self, other: &InstalledPackage) -> Ordering
fn cmp(&self, other: &InstalledPackage) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for InstalledPackage
impl PartialEq for InstalledPackage
Source§impl PartialOrd for InstalledPackage
impl PartialOrd for InstalledPackage
Source§impl Serialize for InstalledPackage
impl Serialize for InstalledPackage
impl Eq for InstalledPackage
impl StructuralPartialEq for InstalledPackage
Auto Trait Implementations§
impl Freeze for InstalledPackage
impl RefUnwindSafe for InstalledPackage
impl Send for InstalledPackage
impl Sync for InstalledPackage
impl Unpin for InstalledPackage
impl UnwindSafe for InstalledPackage
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