pub enum StringOrBool {
Bool(bool),
String(String),
}Expand description
A value that can be either a bool or a template string.
Used by skip, skip_upload, and similar fields across multiple config
structs to support both skip: true and template conditionals like
skip: "{{ if .IsSnapshot }}true{{ endif }}".
Variants§
Implementations§
Source§impl StringOrBool
impl StringOrBool
Sourcepub fn as_bool(&self) -> bool
pub fn as_bool(&self) -> bool
Evaluate this value to a bool. If it’s a string, treat “true” / “1” as true, everything else as false.
Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Return the raw string value for template rendering, or the bool as a string.
Sourcepub fn is_template(&self) -> bool
pub fn is_template(&self) -> bool
Whether this value contains a template expression that needs rendering.
Sourcepub fn try_evaluates_to_true(
&self,
render: impl Fn(&str) -> Result<String>,
) -> Result<bool>
pub fn try_evaluates_to_true( &self, render: impl Fn(&str) -> Result<String>, ) -> Result<bool>
Evaluate whether this value resolves to true.
The value is always run through render (Tera leaves plain literals
unchanged, so this is a no-op for non-templated values). The rendered
result is then compared to "true" / "1" after trimming. A Bool
variant short-circuits without rendering.
Always-rendering keeps this helper consistent with sibling
should_skip_upload (which always renders) — a literal "{{ broken"
surfaces as an Err instead of being silently treated as a false-y
non-template string.
Used for both skip: evaluation (most callers) and output: / sbom:
bool-or-template fields — there is no separate alias; call this directly.
Trait Implementations§
Source§impl Clone for StringOrBool
impl Clone for StringOrBool
Source§fn clone(&self) -> StringOrBool
fn clone(&self) -> StringOrBool
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StringOrBool
impl Debug for StringOrBool
Source§impl Default for StringOrBool
impl Default for StringOrBool
Source§impl JsonSchema for StringOrBool
impl JsonSchema for StringOrBool
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read moreSource§impl PartialEq for StringOrBool
impl PartialEq for StringOrBool
Source§fn eq(&self, other: &StringOrBool) -> bool
fn eq(&self, other: &StringOrBool) -> bool
self and other values to be equal, and is used by ==.