alpm_pkginfo::package_info_v2

Struct PackageInfoV2

Source
pub struct PackageInfoV2 {
Show 20 fields pkgname: Name, pkgbase: Name, pkgver: Version, pkgdesc: PackageDescription, url: Url, builddate: BuildDate, packager: Packager, size: InstalledSize, arch: Architecture, license: Vec<License>, replaces: Vec<PackageRelation>, group: Vec<Group>, conflict: Vec<PackageRelation>, provides: Vec<RelationOrSoname>, backup: Vec<Backup>, depend: Vec<RelationOrSoname>, optdepend: Vec<OptionalDependency>, makedepend: Vec<PackageRelation>, checkdepend: Vec<PackageRelation>, xdata: Vec<ExtraData>,
}
Expand description

PKGINFO version 2

PackageInfoV2 is (exclusively) compatible with data following the v2 specification of the PKGINFO file.

§Examples

use std::str::FromStr;

use alpm_pkginfo::PackageInfoV2;

let pkginfo_data = r#"pkgname = example
pkgbase = example
xdata = pkgtype=pkg
pkgver = 1:1.0.0-1
pkgdesc = A project that does something
url = https://example.org/
builddate = 1729181726
packager = John Doe <john@example.org>
size = 181849963
arch = any
license = GPL-3.0-or-later
license = LGPL-3.0-or-later
replaces = other-package>0.9.0-3
group = package-group
group = other-package-group
conflict = conflicting-package<1.0.0
conflict = other-conflicting-package<1.0.0
provides = some-component
provides = some-other-component=1:1.0.0-1
provides = libexample.so=1-64
provides = libunversionedexample.so=libunversionedexample.so-64
provides = lib:libexample.so.1
backup = etc/example/config.toml
backup = etc/example/other-config.txt
depend = glibc
depend = gcc-libs
depend = libother.so=0-64
depend = libunversioned.so=libunversioned.so-64
depend = lib:libother.so.0
optdepend = python: for special-python-script.py
optdepend = ruby: for special-ruby-script.rb
makedepend = cmake
makedepend = python-sphinx
checkdepend = extra-test-tool
checkdepend = other-extra-test-tool"#;
let pkginfo = PackageInfoV2::from_str(pkginfo_data)?;
assert_eq!(pkginfo.to_string(), pkginfo_data);

Fields§

§pkgname: Name§pkgbase: Name§pkgver: Version§pkgdesc: PackageDescription§url: Url§builddate: BuildDate§packager: Packager§size: InstalledSize§arch: Architecture§license: Vec<License>§replaces: Vec<PackageRelation>§group: Vec<Group>§conflict: Vec<PackageRelation>§provides: Vec<RelationOrSoname>§backup: Vec<Backup>§depend: Vec<RelationOrSoname>§optdepend: Vec<OptionalDependency>§makedepend: Vec<PackageRelation>§checkdepend: Vec<PackageRelation>§xdata: Vec<ExtraData>

Implementations§

Source§

impl PackageInfoV2

Source

pub fn pkgname(&self) -> &Name

Returns the name of the package

Source

pub fn pkgbase(&self) -> &Name

Returns the base name of the package

Source

pub fn pkgver(&self) -> &Version

Returns the version of the package

Source

pub fn pkgdesc(&self) -> &PackageDescription

Returns the description of the package

Source

pub fn url(&self) -> &Url

Returns the URL of the package

Source

pub fn builddate(&self) -> &BuildDate

Returns the build date of the package

Source

pub fn packager(&self) -> &Packager

Returns the packager of the package

Source

pub fn size(&self) -> &InstalledSize

Returns the size of the package

Source

pub fn arch(&self) -> &Architecture

Returns the architecture of the package

Source

pub fn license(&self) -> &[License]

Returns the licenses of the package

Source

pub fn replaces(&self) -> &[PackageRelation]

Returns the packages this package replaces

Source

pub fn group(&self) -> &[Group]

Returns the group of the package

Source

pub fn conflict(&self) -> &[PackageRelation]

Returns the packages this package conflicts with

Source

pub fn provides(&self) -> &[RelationOrSoname]

Returns the packages this package provides

Source

pub fn backup(&self) -> &[Backup]

Returns the backup files of the package

Source

pub fn depend(&self) -> &[RelationOrSoname]

Returns the packages this package depends on

Source

pub fn optdepend(&self) -> &[OptionalDependency]

Returns the optional dependencies of the package

Source

pub fn makedepend(&self) -> &[PackageRelation]

Returns the packages this package is built with

Source

pub fn checkdepend(&self) -> &[PackageRelation]

Returns the packages this package is checked with

Source§

impl PackageInfoV2

Source

pub fn new( pkgname: Name, pkgbase: Name, pkgver: Version, pkgdesc: PackageDescription, url: Url, builddate: BuildDate, packager: Packager, size: InstalledSize, arch: Architecture, license: Vec<License>, replaces: Vec<PackageRelation>, group: Vec<Group>, conflict: Vec<PackageRelation>, provides: Vec<RelationOrSoname>, backup: Vec<Backup>, depend: Vec<RelationOrSoname>, optdepend: Vec<OptionalDependency>, makedepend: Vec<PackageRelation>, checkdepend: Vec<PackageRelation>, xdata: Vec<ExtraData>, ) -> Result<Self, Error>

Create a new PackageInfoV2 from all required components

Source

pub fn xdata(&self) -> &Vec<ExtraData>

Get the extra data

Source

pub fn pkg_type(&self) -> PackageType

Returns the package type.

§Panics

This function panics if the xdata field does not contain a pkgtype key.

Source

fn check_pkg_type(&self) -> Result<(), Error>

Checks if the package type exists.

§Errors

This function returns an error in the following cases:

  • if the xdata field does not contain a pkgtype key.
  • if the pkgtype key does not contain a valid package type.

Trait Implementations§

Source§

impl Clone for PackageInfoV2

Source§

fn clone(&self) -> PackageInfoV2

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PackageInfoV2

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for PackageInfoV2

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for PackageInfoV2

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromStr for PackageInfoV2

Source§

fn from_str(input: &str) -> Result<PackageInfoV2, Self::Err>

Create a PackageInfoV2 from a &str

§Errors

Returns an Error if any of the fields in input can not be validated according to PackageInfoV2 or their respective own specification.

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

impl Serialize for PackageInfoV2

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T