#[non_exhaustive]pub struct Srcinfo {
pub comment: String,
pub base: PackageBase,
pub pkg: Package,
pub pkgs: Vec<Package>,
}
Expand description
A complete representation of a .SRCINFO file.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.comment: String
The header comment
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§
Source§impl Srcinfo
impl Srcinfo
Sourcepub fn from_buf<T: BufRead>(b: T) -> Result<Srcinfo, Error>
pub fn from_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.
// from_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::from_buf(buf)?;
Sourcepub fn from_path<P: AsRef<Path>>(s: P) -> Result<Srcinfo, Error>
pub fn from_path<P: AsRef<Path>>(s: P) -> Result<Srcinfo, Error>
Parse the file at a given path.
use srcinfo::Srcinfo;
let file = ".SRCINFO";
let srcinfo = Srcinfo::from_path(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 pkgnames(&self) -> impl Iterator<Item = &str>
pub fn pkgnames(&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.pkgnames().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");
pub fn comment(&self) -> &str
pub fn pkgbase(&self) -> &str
pub fn pkgver(&self) -> &str
pub fn pkgrel(&self) -> &str
pub fn epoch(&self) -> Option<&str>
pub fn source(&self) -> &ArchVecs
pub fn valid_pgp_keys(&self) -> &[String]
pub fn no_extract(&self) -> &[String]
pub fn md5sums(&self) -> &ArchVecs
pub fn sha1sums(&self) -> &ArchVecs
pub fn sha224sums(&self) -> &ArchVecs
pub fn sha256sums(&self) -> &ArchVecs
pub fn sha384sums(&self) -> &ArchVecs
pub fn sha512sums(&self) -> &ArchVecs
pub fn b2sums(&self) -> &ArchVecs
pub fn makedepends(&self) -> &ArchVecs
pub fn checkdepends(&self) -> &ArchVecs
pub fn pkgdesc(&self) -> Option<&str>
pub fn arch(&self) -> &[String]
pub fn url(&self) -> Option<&str>
pub fn license(&self) -> &[String]
pub fn groups(&self) -> &[String]
pub fn depends(&self) -> &ArchVecs
pub fn optdepends(&self) -> &ArchVecs
pub fn provides(&self) -> &ArchVecs
pub fn conflicts(&self) -> &ArchVecs
pub fn replaces(&self) -> &ArchVecs
pub fn backup(&self) -> &[String]
pub fn options(&self) -> &[String]
pub fn install(&self) -> Option<&str>
pub fn changelog(&self) -> Option<&str>
Trait Implementations§
Source§impl Ord for Srcinfo
impl Ord for Srcinfo
Source§impl PartialOrd for Srcinfo
impl PartialOrd for Srcinfo
impl Eq for Srcinfo
impl StructuralPartialEq for Srcinfo
Auto Trait Implementations§
impl Freeze for Srcinfo
impl RefUnwindSafe for Srcinfo
impl Send for Srcinfo
impl Sync for Srcinfo
impl Unpin for Srcinfo
impl UnwindSafe for Srcinfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more