DbDescFileV2

Struct DbDescFileV2 

Source
pub struct DbDescFileV2 {
Show 20 fields pub name: Name, pub version: Version, pub base: PackageBaseName, pub description: PackageDescription, pub url: Option<Url>, pub arch: Architecture, pub builddate: BuildDate, pub installdate: BuildDate, pub packager: Packager, pub size: InstalledSize, pub groups: Vec<Group>, pub reason: PackageInstallReason, pub license: Vec<License>, pub validation: PackageValidation, pub replaces: Vec<PackageRelation>, pub depends: Vec<PackageRelation>, pub optdepends: Vec<OptionalDependency>, pub conflicts: Vec<PackageRelation>, pub provides: Vec<PackageRelation>, pub xdata: ExtraData,
}
Expand description

DB desc version 2

DbDescFileV2 extends DbDescFileV1 according to the second revision of the alpm-db-desc specification. It introduces an additional %XDATA% section, which allows storing structured, implementation-defined metadata.

§Examples

use std::str::FromStr;

use alpm_db::desc::DbDescFileV2;

let desc_data = r#"%NAME%
foo

%VERSION%
1.0.0-1

%BASE%
foo

%DESC%
An example package

%URL%
https://example.org/

%ARCH%
x86_64

%BUILDDATE%
1733737242

%INSTALLDATE%
1733737243

%PACKAGER%
Foobar McFooface <foobar@mcfooface.org>

%SIZE%
123

%GROUPS%
utils
cli

%REASON%
1

%LICENSE%
MIT
Apache-2.0

%VALIDATION%
pgp

%REPLACES%
pkg-old

%DEPENDS%
glibc

%OPTDEPENDS%
optpkg

%CONFLICTS%
foo-old

%PROVIDES%
foo-virtual

%XDATA%
pkgtype=pkg

"#;

// Parse a DB DESC file in version 2 format.
let db_desc = DbDescFileV2::from_str(desc_data)?;
// Convert back to its canonical string representation.
assert_eq!(db_desc.to_string(), desc_data);

Fields§

§name: Name

The name of the package.

§version: Version

The version of the package.

§base: PackageBaseName

The base name of the package (used in split packages).

§description: PackageDescription

The description of the package.

§url: Option<Url>

The URL for the project of the package.

§arch: Architecture

The architecture of the package.

§builddate: BuildDate

The date at which the build of the package started.

§installdate: BuildDate

The date at which the package has been installed on the system.

§packager: Packager

The User ID of the entity, that built the package.

§size: InstalledSize

The optional size of the (uncompressed and unpacked) package contents in bytes.

§groups: Vec<Group>

Groups the package belongs to.

§reason: PackageInstallReason

Optional install reason.

§license: Vec<License>

Licenses that apply to the package.

§validation: PackageValidation

Validation methods used for the package archive.

§replaces: Vec<PackageRelation>

Packages this one replaces.

§depends: Vec<PackageRelation>

Required runtime dependencies.

§optdepends: Vec<OptionalDependency>

Optional dependencies that enhance the package.

§conflicts: Vec<PackageRelation>

Conflicting packages that cannot be installed together.

§provides: Vec<PackageRelation>

Virtual packages or capabilities provided by this one.

§xdata: ExtraData

Structured extra metadata, implementation-defined.

Trait Implementations§

Source§

impl Clone for DbDescFileV2

Source§

fn clone(&self) -> DbDescFileV2

Returns a duplicate 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 DbDescFileV2

Source§

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

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

impl<'de> Deserialize<'de> for DbDescFileV2

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 DbDescFileV2

Source§

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

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

impl From<DbDescFileV2> for DbDescFileV1

Source§

fn from(v2: DbDescFileV2) -> Self

Converts a DbDescFileV2 into a DbDescFileV1.

§Note

This drops the xdata field of the DbDescFileV2, which provides additional information about a package.

Source§

impl FromStr for DbDescFileV2

Source§

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

Creates a DbDescFileV2 from a string slice.

Parses the input according to the alpm-db-descv2 specification (version 2) and constructs a structured DbDescFileV2 representation including the %XDATA% section.

§Examples
use std::str::FromStr;

use alpm_db::desc::DbDescFileV2;

let desc_data = r#"%NAME%
foo

%VERSION%
1.0.0-1

%BASE%
foo

%DESC%
An example package

%URL%
https://example.org

%ARCH%
x86_64

%BUILDDATE%
1733737242

%INSTALLDATE%
1733737243

%PACKAGER%
Foobar McFooface <foobar@mcfooface.org>

%SIZE%
123

%VALIDATION%
pgp

%XDATA%
pkgtype=pkg

"#;

let db_desc = DbDescFileV2::from_str(desc_data)?;
assert_eq!(db_desc.name.to_string(), "foo");
§Errors

Returns an error if:

  • the input cannot be parsed into valid sections,
  • or required fields are missing or malformed.
Source§

type Err = Error

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

impl PartialEq for DbDescFileV2

Source§

fn eq(&self, other: &DbDescFileV2) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for DbDescFileV2

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
Source§

impl TryFrom<Vec<Section>> for DbDescFileV2

Source§

fn try_from(sections: Vec<Section>) -> Result<Self, Self::Error>

Tries to create a DbDescFileV2 from a list of parsed Sections.

Reuses the parsing logic from DbDescFileV1 for all common fields, and adds support for the %XDATA% section introduced in the alpm-db-descv2 specification.

§Errors

Returns an error if:

  • any required field is missing,
  • a section appears more than once,
  • or the %XDATA% section is missing or malformed.
Source§

type Error = Error

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

impl StructuralPartialEq for DbDescFileV2

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
§

impl<T> AnyEq for T
where T: Any + PartialEq,

§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

§

fn as_any(&self) -> &(dyn Any + 'static)

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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>,