pub struct LoadedRule {Show 19 fields
pub identifier: String,
pub license_expression: String,
pub text: String,
pub rule_kind: RuleKind,
pub is_false_positive: bool,
pub is_required_phrase: bool,
pub relevance: Option<u8>,
pub minimum_coverage: Option<u8>,
pub has_stored_minimum_coverage: bool,
pub is_continuous: bool,
pub referenced_filenames: Option<Vec<String>>,
pub ignorable_urls: Option<Vec<String>>,
pub ignorable_emails: Option<Vec<String>>,
pub ignorable_copyrights: Option<Vec<String>>,
pub ignorable_holders: Option<Vec<String>>,
pub ignorable_authors: Option<Vec<String>>,
pub language: Option<String>,
pub notes: Option<String>,
pub is_deprecated: bool,
}Expand description
Loader-stage representation of a rule.
This struct contains parsed and normalized data from a .RULE or .LICENSE file.
It is serialized at build time and deserialized at runtime, then converted
to a runtime Rule during the build stage.
Fields§
§identifier: StringUnique identifier derived from the filename (e.g., “mit.LICENSE”).
license_expression: StringLicense expression string using SPDX syntax and ScanCode license keys. For false-positive rules with no source expression, this is set to “unknown”.
text: StringPattern text to match, trimmed and normalized.
rule_kind: RuleKindClassification of this rule, derived from source rule-kind booleans.
is_false_positive: boolTrue if exact matches to this rule are false positives.
is_required_phrase: boolTrue if this rule text is a required phrase.
relevance: Option<u8>Relevance score 0-100 (100 is most relevant). Stored as Option to distinguish between explicit 100 and default 100.
minimum_coverage: Option<u8>Minimum match coverage percentage (0-100) if specified.
has_stored_minimum_coverage: boolTrue if minimum_coverage was explicitly stored in source frontmatter.
is_continuous: boolTokens must appear in order if true.
referenced_filenames: Option<Vec<String>>Filenames where this rule should be considered.
ignorable_urls: Option<Vec<String>>URLs that should be ignored when found in this rule text.
ignorable_emails: Option<Vec<String>>Emails that should be ignored when found in this rule text.
ignorable_copyrights: Option<Vec<String>>Copyrights that should be ignored when found in this rule text.
ignorable_holders: Option<Vec<String>>Holder names that should be ignored when found in this rule text.
Author names that should be ignored when found in this rule text.
language: Option<String>Programming language for the rule if specified.
notes: Option<String>Free text notes.
is_deprecated: boolWhether this rule is deprecated.
Implementations§
Source§impl LoadedRule
Loader-stage normalization functions for rule data.
impl LoadedRule
Loader-stage normalization functions for rule data.
Sourcepub fn derive_identifier(filename: &str) -> String
pub fn derive_identifier(filename: &str) -> String
Derive identifier from filename.
Returns the filename as-is, which serves as the unique identifier.
Sourcepub fn derive_rule_kind(
is_license_text: bool,
is_license_notice: bool,
is_license_reference: bool,
is_license_tag: bool,
is_license_intro: bool,
is_license_clue: bool,
) -> Result<RuleKind, RuleKindError>
pub fn derive_rule_kind( is_license_text: bool, is_license_notice: bool, is_license_reference: bool, is_license_tag: bool, is_license_intro: bool, is_license_clue: bool, ) -> Result<RuleKind, RuleKindError>
Derive rule kind from source rule-kind booleans.
Returns an error if multiple flags are set.
Sourcepub fn normalize_license_expression(
expression: Option<&str>,
is_false_positive: bool,
) -> Result<String, LicenseExpressionError>
pub fn normalize_license_expression( expression: Option<&str>, is_false_positive: bool, ) -> Result<String, LicenseExpressionError>
Normalize license expression.
- Strips trivial outer parentheses
- For false-positive rules with no expression, returns “unknown”
- For non-false-positive rules with no expression, returns an error
Sourcepub fn normalize_optional_string(s: Option<&str>) -> Option<String>
pub fn normalize_optional_string(s: Option<&str>) -> Option<String>
Normalize optional string field.
Returns None for empty strings, Some(trimmed) otherwise.
Sourcepub fn normalize_optional_list(list: Option<&[String]>) -> Option<Vec<String>>
pub fn normalize_optional_list(list: Option<&[String]>) -> Option<Vec<String>>
Normalize optional string list.
Returns None for empty lists, Some(list) with trimmed strings otherwise.
Sourcepub fn validate_rule_kind_flags(
rule_kind: RuleKind,
is_false_positive: bool,
) -> Result<(), RuleKindError>
pub fn validate_rule_kind_flags( rule_kind: RuleKind, is_false_positive: bool, ) -> Result<(), RuleKindError>
Validate rule-kind flags against false_positive flag.
- False-positive rules must NOT have any is_license_* flags set
- Non-false-positive rules MUST have exactly one is_license_* flag set
Trait Implementations§
Source§impl Clone for LoadedRule
impl Clone for LoadedRule
Source§fn clone(&self) -> LoadedRule
fn clone(&self) -> LoadedRule
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LoadedRule
impl Debug for LoadedRule
Source§impl<'de> Deserialize<'de> for LoadedRule
impl<'de> Deserialize<'de> for LoadedRule
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for LoadedRule
impl PartialEq for LoadedRule
Source§impl Serialize for LoadedRule
impl Serialize for LoadedRule
impl Eq for LoadedRule
impl StructuralPartialEq for LoadedRule
Auto Trait Implementations§
impl Freeze for LoadedRule
impl RefUnwindSafe for LoadedRule
impl Send for LoadedRule
impl Sync for LoadedRule
impl Unpin for LoadedRule
impl UnsafeUnpin for LoadedRule
impl UnwindSafe for LoadedRule
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more