alpm_srcinfo::source_info

Struct SourceInfo

Source
pub struct SourceInfo {
    pub base: PackageBase,
    pub packages: Vec<Package>,
}
Expand description

The representation of SRCINFO data.

Provides access to a PackageBase which tracks all data in a pkgbase section and a list of Package instances that provide the accumulated data of all pkgname sections.

This is the entry point for parsing SRCINFO files. Once created, Self::packages_for_architecture can be used to create usable MergedPackages.

Fields§

§base: PackageBase§packages: Vec<Package>

Implementations§

Source§

impl SourceInfo

Source

pub fn from_file(path: &Path) -> Result<SourceInfoResult, Error>

Reads the file at the specified path and converts it into a SourceInfo struct.

§Errors

Returns an Error if the file cannot be read or parsed. Returns an error array with potentially un/-recoverable errors, this needs to be explicitly handled by the user.

Source

pub fn from_string(content: &str) -> Result<SourceInfoResult, Error>

Parses a SRCINFO file’s content into a SourceInfo struct.

§Error

This function returns two types of errors.

  1. An Error is returned if the input is, for example, invalid UTF-8 or if the input SRCINFO file couldn’t be parsed due to invalid syntax.
  2. If the parsing was successful, a SourceInfoResult is returned, which wraps a possibly invalid SourceInfo and possible SourceInfoErrors. SourceInfoErrors contains all errors and lint/deprecation warnings that’re encountered while interpreting the SRCINFO file.
use alpm_srcinfo::SourceInfo;
use alpm_types::{Architecture, Name, PackageRelation};

let source_info_data = r#"
pkgbase = example
    pkgver = 1.0.0
    epoch = 1
    pkgrel = 1
    pkgdesc = A project that does something
    url = https://example.org/
    arch = x86_64
    depends = glibc
    optdepends = python: for special-python-script.py
    makedepends = cmake
    checkdepends = extra-test-tool

pkgname = example
    depends = glibc
    depends = gcc-libs
"#;

// Parse the file. This might already error if the file cannot be parsed on a low level.
let source_info_result = SourceInfo::from_string(source_info_data)?;
// Make sure there're no other unrecoverable errors.
let source_info = source_info_result.source_info()?;
Source

pub fn from_raw( content: SourceInfoContent, ) -> (SourceInfo, Vec<SourceInfoError>)

Reads raw SourceInfoContent from a first parsing step and converts it into a SourceInfo.

Instead of a Result this function returns a tuple of SourceInfo and a vector of SourceInfoErrors. The caller is expected to handle the vector of SourceInfoErrors, which may only consist of linting errors that can be ignored.

Source

pub fn packages_for_architecture( &self, architecture: Architecture, ) -> MergedPackagesIterator<'_>

Get an iterator over all packages

use alpm_srcinfo::{MergedPackage, SourceInfo};
use alpm_types::{Architecture, Name, PackageRelation};

let source_info_data = r#"
pkgbase = example
    pkgver = 1.0.0
    epoch = 1
    pkgrel = 1
    arch = x86_64

pkgname = example
    pkgdesc = Example split package

pkgname = example_other
    pkgdesc = The other example split package
"#;
// Parse the file. This might already error if the file cannot be parsed on a low level.
let result = SourceInfo::from_string(source_info_data)?;
// Make sure there're aren't unrecoverable logic errors, such as missing values.
let source_info = result.source_info()?;

/// Get all merged package representations for the x86_64 architecture.
let mut packages = source_info.packages_for_architecture(Architecture::X86_64);

let example = packages.next().unwrap();
assert_eq!(
    example.description,
    Some("Example split package".to_string())
);

let example_other = packages.next().unwrap();
assert_eq!(
    example_other.description,
    Some("The other example split package".to_string())
);

Trait Implementations§

Source§

impl Clone for SourceInfo

Source§

fn clone(&self) -> SourceInfo

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 SourceInfo

Source§

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

Formats the value using the given formatter. 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> 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, 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.
§

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

§

impl<T> MaybeSendSync for T