Enum pep508_rs::MarkerTree
source · pub enum MarkerTree {
Expression(MarkerExpression),
And(Vec<MarkerTree>),
Or(Vec<MarkerTree>),
}
Expand description
Represents one of the nested marker expressions with and/or/parentheses
Variants§
Expression(MarkerExpression)
A simple expression such as python_version > "3.8"
And(Vec<MarkerTree>)
An and between nested expressions, such as
python_version > "3.8" and implementation_name == 'cpython'
Or(Vec<MarkerTree>)
An or between nested expressions, such as
python_version > "3.8" or implementation_name == 'cpython'
Implementations§
source§impl MarkerTree
impl MarkerTree
sourcepub fn evaluate(&self, env: &MarkerEnvironment, extras: &[ExtraName]) -> bool
pub fn evaluate(&self, env: &MarkerEnvironment, extras: &[ExtraName]) -> bool
Does this marker apply in the given environment?
sourcepub fn evaluate_reporter(
&self,
env: &MarkerEnvironment,
extras: &[ExtraName],
reporter: &mut impl FnMut(MarkerWarningKind, String, &MarkerExpression)
) -> bool
pub fn evaluate_reporter( &self, env: &MarkerEnvironment, extras: &[ExtraName], reporter: &mut impl FnMut(MarkerWarningKind, String, &MarkerExpression) ) -> bool
Same as Self::evaluate
, but instead of using logging to warn, you can pass your own
handler for warnings
sourcepub fn evaluate_extras_and_python_version(
&self,
extras: &HashSet<ExtraName>,
python_versions: &[Version]
) -> bool
pub fn evaluate_extras_and_python_version( &self, extras: &HashSet<ExtraName>, python_versions: &[Version] ) -> bool
Checks if the requirement should be activated with the given set of active extras and a set
of possible python versions (from requires-python
) without evaluating the remaining
environment markers, i.e. if there is potentially an environment that could activate this
requirement.
Note that unlike Self::evaluate
this does not perform any checks for bogus expressions but
will simply return true. As caller you should separately perform a check with an environment
and forward all warnings.
sourcepub fn evaluate_collect_warnings(
&self,
env: &MarkerEnvironment,
extras: &[ExtraName]
) -> (bool, Vec<(MarkerWarningKind, String, String)>)
pub fn evaluate_collect_warnings( &self, env: &MarkerEnvironment, extras: &[ExtraName] ) -> (bool, Vec<(MarkerWarningKind, String, String)>)
Same as Self::evaluate
, but instead of using logging to warn, you get a Vec with all
warnings collected
Trait Implementations§
source§impl Clone for MarkerTree
impl Clone for MarkerTree
source§fn clone(&self) -> MarkerTree
fn clone(&self) -> MarkerTree
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for MarkerTree
impl Debug for MarkerTree
source§impl Display for MarkerTree
impl Display for MarkerTree
source§impl FromStr for MarkerTree
impl FromStr for MarkerTree
source§impl Hash for MarkerTree
impl Hash for MarkerTree
source§impl PartialEq for MarkerTree
impl PartialEq for MarkerTree
source§fn eq(&self, other: &MarkerTree) -> bool
fn eq(&self, other: &MarkerTree) -> bool
self
and other
values to be equal, and is used
by ==
.