[][src]Struct srcinfo::Srcinfo

pub struct Srcinfo {
    pub base: PackageBase,
    pub pkg: Package,
    pub pkgs: Vec<Package>,
}

A complete representation of a .SRCINFO file.

Fields

base: PackageBase

Fields belonging to the pkgbase

pkg: Package

Fields belonging to the pkgbase, may be overridden inside of each package

pkgs: Vec<Package>

The packages this .SRCINFO contains

Implementations

impl Srcinfo[src]

pub fn parse_buf<T: BufRead>(b: T) -> Result<Srcinfo, Error>[src]

Parse a BufRead. If you are parsing a string directly from_str() should be used instead.

// from_str() would be better here.
// parse_buf() is only used for the sake of example.
use srcinfo::Srcinfo;

let buf = "
pkgbase = example
pkgver = 1.5.0
pkgrel = 5

pkgname = example".as_bytes();

Srcinfo::parse_buf(buf)?;

pub fn parse_file<P: AsRef<Path>>(s: P) -> Result<Srcinfo, Error>[src]

Parse the file at a given path.

use srcinfo::Srcinfo;

let file = ".SRCINFO";
let srcinfo = Srcinfo::parse_file(file)?;

pub fn version(&self) -> String[src]

Builds a complete version string in the format: "epoch-pkgver-pkgrel".

If the epoch is none then the epoch and connecting hyphen will be omitted.

use srcinfo::Srcinfo;

let srcinfo: Srcinfo = "
pkgbase = example
pkgver = 1.5.0
pkgrel = 5

pkgname = example".parse()?;

assert_eq!(srcinfo.version(), "1.5.0-5");

pub fn names(&self) -> impl Iterator<Item = &str>[src]

Returns an Iterator over all the pkgnames the Package contains.

use srcinfo::Srcinfo;

let srcinfo: Srcinfo = "
pkgbase = example
pkgver = 1.5.0
pkgrel = 5
pkgdesc = 1

pkgname = example

pkgname = foo
pkgdesc = 2

pkgname = bar
pkgdesc = 3".parse()?;

let mut names = srcinfo.names().collect::<Vec<_>>();
assert_eq!(names, vec!["example", "foo", "bar"]);

pub fn pkg<S: AsRef<str>>(&self, name: S) -> Option<&Package>[src]

Searches for a package with a given pkgname

use srcinfo::Srcinfo;

let srcinfo: Srcinfo = "
pkgbase = example
pkgver = 1.5.0
pkgrel = 5
pkgdesc = 1

pkgname = example

pkgname = foo
pkgdesc = 2

pkgname = bar
pkgdesc = 3".parse()?;

let pkg = srcinfo.pkg("foo").unwrap();
assert_eq!(pkg.pkgname, "foo");

Trait Implementations

impl Clone for Srcinfo[src]

impl Debug for Srcinfo[src]

impl Default for Srcinfo[src]

impl Eq for Srcinfo[src]

impl FromStr for Srcinfo[src]

type Err = Error

The associated error which can be returned from parsing.

impl Hash for Srcinfo[src]

impl Ord for Srcinfo[src]

impl PartialEq<Srcinfo> for Srcinfo[src]

impl PartialOrd<Srcinfo> for Srcinfo[src]

impl StructuralEq for Srcinfo[src]

impl StructuralPartialEq for Srcinfo[src]

Auto Trait Implementations

impl RefUnwindSafe for Srcinfo

impl Send for Srcinfo

impl Sync for Srcinfo

impl Unpin for Srcinfo

impl UnwindSafe for Srcinfo

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.