pub struct BridgeOutput {
pub package_base: HashMap<Keyword, Value>,
pub packages: HashMap<RawPackageName, HashMap<Keyword, ClearableValue>>,
pub functions: Vec<RawPackageName>,
}
Expand description
Represents the raw parsed, but not yet typed output of the alpm-pkgbuild-bridge
script.
Fields§
§package_base: HashMap<Keyword, Value>
The map of all assigned keywords in the pkgbase
section of the bridge output.
packages: HashMap<RawPackageName, HashMap<Keyword, ClearableValue>>
The map of all assigned keywords in the package
section of the bridge output.
The keywords are grouped by package name.
functions: Vec<RawPackageName>
The list of all package function names that are declared in the bridge output.
Implementations§
Source§impl BridgeOutput
impl BridgeOutput
Sourcepub fn from_file(pkgbuild_path: &Path) -> Result<Self, Error>
pub fn from_file(pkgbuild_path: &Path) -> Result<Self, Error>
Creates a BridgeOutput
from a PKGBUILD
at a given path, by calling the
alpm-pkgbuild-bridge
script.
Sourcepub fn from_script_output(input: &str) -> Result<Self, Error>
pub fn from_script_output(input: &str) -> Result<Self, Error>
Creates a BridgeOutput
from some alpm-pkgbuild-bridge
script output.
This function is mostly exposed for testing, consider using Self::from_file
.
Sourcefn parser(input: &mut &str) -> ModalResult<Self>
fn parser(input: &mut &str) -> ModalResult<Self>
Parse some given [alpm-pkgbuild-bridge
] script output into Self
.
Use Self::from_script_output
for convenient error handling.
Recognizes a BridgeOutput
in the output of the alpm-pkgbuild-bridge
script.
§Errors
Returns an error if no BridgeOutput
can be found in input
.
Sourcefn package_base_line(input: &mut &str) -> ModalResult<(Keyword, Value)>
fn package_base_line(input: &mut &str) -> ModalResult<(Keyword, Value)>
Sourcefn packages(
input: &mut &str,
) -> ModalResult<HashMap<RawPackageName, HashMap<Keyword, ClearableValue>>>
fn packages( input: &mut &str, ) -> ModalResult<HashMap<RawPackageName, HashMap<Keyword, ClearableValue>>>
Recognizes an entire section of package variable declarations.
Delegates to BridgeOutput::package_line
to recognize singular tuples of
RawPackageName
, Keyword
and ClearableValue
per line and combines the data in a
HashMap
.
Backtracks as soon as the next section is hit.
§Errors
Returns an error if BridgeOutput::package_line
does not find at least one line in
input
.
Sourcefn package_line(
input: &mut &str,
) -> ModalResult<(RawPackageName, Keyword, ClearableValue)>
fn package_line( input: &mut &str, ) -> ModalResult<(RawPackageName, Keyword, ClearableValue)>
Recognizes a tuple of RawPackageName
, Keyword
and ClearableValue
in a string
slice.
The tuple represents a single package variable line.
Backtracks as soon any other line prefix than FUNCTION
is encountered.
§Errors
Returns an error if one of the components (RawPackageName
, Keyword
and
ClearableValue
) is not found in input
.
Sourcefn functions(input: &mut &str) -> ModalResult<Vec<RawPackageName>>
fn functions(input: &mut &str) -> ModalResult<Vec<RawPackageName>>
Recognizes a list of RawPackageName
s in a string slice.
Delegates to BridgeOutput::function_line
to recognize each singular RawPackageName
.
This parser may return an empty array, which is the case for alpm-meta-packages without a
package
function.
§Errors
Returns an error if BridgeOutput::function_line
fails.
Sourcefn function_line(input: &mut &str) -> ModalResult<RawPackageName>
fn function_line(input: &mut &str) -> ModalResult<RawPackageName>
Recognizes a RawPackageName
in a string slice.
§Errors
Returns an error if no RawPackageName
can be found in input
.
Trait Implementations§
Source§impl Clone for BridgeOutput
impl Clone for BridgeOutput
Source§fn clone(&self) -> BridgeOutput
fn clone(&self) -> BridgeOutput
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more