pub enum Value {
Single(String),
Array(Vec<String>),
}Expand description
A single value or a list of values declared in the output of the alpm-pkgbuild-bridge script.
Both parser functions ensure that at least one value exists.
Variants§
Implementations§
Source§impl Value
impl Value
Sourcepub fn as_vec(&self) -> Vec<&String>
pub fn as_vec(&self) -> Vec<&String>
Returns the values of &self in vector representation.
This is useful for values that may be available as both single values and arrays.
Sourcepub fn as_owned_vec(self) -> Vec<String>
pub fn as_owned_vec(self) -> Vec<String>
Returns the values of self in vector representation.
This is useful for values that may be available as both single values and arrays.
Sourcepub fn has_value(&self) -> bool
pub fn has_value(&self) -> bool
Checks whether this holds a value.
Returns true if self is Value::Single (they always have a value set by definition),
or if self is Value::Array and contains at least one element.
Returns false in all other cases.
Sourcefn single_till_newline(input: &mut &str) -> ModalResult<Self>
fn single_till_newline(input: &mut &str) -> ModalResult<Self>
Recognizes a Value::Single in a string slice while handling the surroundings.
Consumes leading and trailing spaces while also consuming newlines.
Also allows variables at the end of the file where no newline is found.
Calls Value::parse_next_value for variable parsing.
§Errors
Returns an error if no Value::Single can be recognized in input.
Sourcefn list_till_newline(input: &mut &str) -> ModalResult<Self>
fn list_till_newline(input: &mut &str) -> ModalResult<Self>
Recognizes a Value::Array in a string slice while handling the surroundings.
Consumes leading and trailing spaces while also consuming newlines.
Also allows variables at the end of the file where no newline is found.
Calls Self::parse_next_value for variable parsing.
§Errors
Returns an error if no Value::Array is found in input.
Sourcepub fn parse_next_value(input: &mut &str) -> ModalResult<String>
pub fn parse_next_value(input: &mut &str) -> ModalResult<String>
Recognizes a Value::Single in a string slice.
Calls Value::variable_character to handle escaped characters in input.
§Examples
"This is a string value\" with escaped \\ characters"§Errors
Returns an error if no Value::Single is found in input.