pub struct Srcinfo {
pub base: PackageBase,
pub pkg: Package,
pub pkgs: Vec<Package>,
}
Expand description
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
sourceimpl Srcinfo
impl Srcinfo
sourcepub fn parse_buf<T: BufRead>(b: T) -> Result<Srcinfo, Error>
pub fn parse_buf<T: BufRead>(b: T) -> Result<Srcinfo, Error>
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)?;
sourcepub fn parse_file<P: AsRef<Path>>(s: P) -> Result<Srcinfo, Error>
pub fn parse_file<P: AsRef<Path>>(s: P) -> Result<Srcinfo, Error>
Parse the file at a given path.
use srcinfo::Srcinfo;
let file = ".SRCINFO";
let srcinfo = Srcinfo::parse_file(file)?;
sourcepub fn version(&self) -> String
pub fn version(&self) -> String
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");
sourcepub fn names(&self) -> impl Iterator<Item = &str>
pub fn names(&self) -> impl Iterator<Item = &str>
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"]);
sourcepub fn pkg<S: AsRef<str>>(&self, name: S) -> Option<&Package>
pub fn pkg<S: AsRef<str>>(&self, name: S) -> Option<&Package>
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
sourceimpl Ord for Srcinfo
impl Ord for Srcinfo
1.21.0 · sourcefn 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
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialOrd<Srcinfo> for Srcinfo
impl PartialOrd<Srcinfo> for Srcinfo
sourcefn partial_cmp(&self, other: &Srcinfo) -> Option<Ordering>
fn partial_cmp(&self, other: &Srcinfo) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for Srcinfo
impl StructuralEq for Srcinfo
impl StructuralPartialEq for Srcinfo
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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more