[−][src]Struct pkgsrc::summary::Summaries
A collection of pkg_summary(5)
entries.
Each pkg_summary entry should be separated by a single blank line.
The Write
trait is implemented, and is the method by which an existing
pkg_summary file can be parsed into a new Summaries
.
Display
is also implemented so printing the newly created collection
will result in a correctly formed pkg_summary file.
Example
use pkgsrc::summary::Summaries; use unindent::unindent; let mut pkgsummary = Summaries::new(); let pkginfo = unindent(r#" BUILD_DATE=2019-08-12 15:58:02 +0100 CATEGORIES=devel pkgtools COMMENT=This is a test DESCRIPTION=A test description DESCRIPTION= DESCRIPTION=This is a multi-line variable MACHINE_ARCH=x86_64 OPSYS=Darwin OS_VERSION=18.7.0 PKGNAME=testpkg-1.0 PKGPATH=pkgtools/testpkg PKGTOOLS_VERSION=20091115 SIZE_PKG=4321 "#); /* * Obviously 3 identical entries is useless, but serves as an example. */ let input = format!("{}\n{}\n{}\n", pkginfo, pkginfo, pkginfo); std::io::copy(&mut input.as_bytes(), &mut pkgsummary); /* * Output should match what we received. */ let output = format!("{}", pkgsummary); assert_eq!(input.as_bytes(), output.as_bytes()); assert_eq!(pkgsummary.entries().len(), 3); /* * Use each Summary entry to emulate pkg_info output. This will hopefully * be implemented as a proper Iterator at some point. Note that these * values are safe to unwrap as they are required variables and have been * checked to exist when creating the entries. */ for sum in pkgsummary.entries() { println!("{:20} {}", sum.pkgname().unwrap(), sum.comment().unwrap()); }
Methods
impl Summaries
[src]
ⓘImportant traits for Summariespub fn new() -> Summaries
[src]
ⓘImportant traits for Summaries
Return a new Summaries with default values.
pub fn entries(&self) -> &Vec<Summary>
[src]
Return vector of parsed Summary records.
pub fn entries_mut(&mut self) -> &mut Vec<Summary>
[src]
Return mutable vector of parsed Summary records.
Trait Implementations
impl Default for Summaries
[src]
impl Debug for Summaries
[src]
impl Display for Summaries
[src]
impl Write for Summaries
[src]
fn write(&mut self, input: &[u8]) -> Result<usize>
[src]
fn flush(&mut self) -> Result<()>
[src]
fn write_vectored(&mut self, bufs: &[IoSlice]) -> Result<usize, Error>
1.36.0[src]
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0[src]
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
Auto Trait Implementations
impl Send for Summaries
impl Unpin for Summaries
impl Sync for Summaries
impl UnwindSafe for Summaries
impl RefUnwindSafe for Summaries
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,