pub struct Rule {Show 36 fields
pub identifier: String,
pub license_expression: String,
pub text: String,
pub tokens: Vec<TokenId>,
pub rule_kind: RuleKind,
pub is_false_positive: bool,
pub is_required_phrase: bool,
pub is_from_license: bool,
pub relevance: u8,
pub minimum_coverage: Option<u8>,
pub has_stored_minimum_coverage: bool,
pub is_continuous: bool,
pub required_phrase_spans: Vec<Range<usize>>,
pub stopwords_by_pos: HashMap<usize, usize>,
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 length_unique: usize,
pub high_length_unique: usize,
pub high_length: usize,
pub min_matched_length: usize,
pub min_high_matched_length: usize,
pub min_matched_length_unique: usize,
pub min_high_matched_length_unique: usize,
pub is_small: bool,
pub is_tiny: bool,
pub starts_with_license: bool,
pub ends_with_license: bool,
pub is_deprecated: bool,
pub spdx_license_key: Option<String>,
pub other_spdx_license_keys: Vec<String>,
}Expand description
Rule metadata loaded from .LICENSE and .RULE files.
Fields§
§identifier: StringUnique identifier for this rule (e.g., “mit.LICENSE”, “gpl-2.0_12.RULE”) Used for sorting to match Python’s attr.s field order. This is the primary sort key after rid (which is None at sort time in Python).
license_expression: StringLicense expression string using SPDX syntax and ScanCode license keys
text: StringPattern text to match
tokens: Vec<TokenId>Token IDs for the text (assigned during indexing)
rule_kind: RuleKindClassification of this rule.
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. A required phrase is an essential section of the rule text which must be present in the case of partial matches.
is_from_license: boolTrue if this rule was created from a license file (not a .RULE file)
relevance: u8Relevance score 0-100 (100 is most relevant)
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
required_phrase_spans: Vec<Range<usize>>Token position spans for required phrases parsed from {{…}} markers. Each span represents positions in the rule text that MUST be matched.
stopwords_by_pos: HashMap<usize, usize>Mapping from token position to count of stopwords at that position. Used for required phrase validation.
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
length_unique: usizeCount of unique token IDs in the rule (computed during indexing)
high_length_unique: usizeCount of unique legalese token IDs (tokens with ID < len_legalese)
high_length: usizeTotal count of legalese token occurrences (with duplicates)
min_matched_length: usizeMinimum matched length threshold (occurrences-based)
min_high_matched_length: usizeMinimum high-value token matched length threshold (occurrences-based)
min_matched_length_unique: usizeMinimum matched length threshold (unique tokens)
min_high_matched_length_unique: usizeMinimum high-value token matched length threshold (unique tokens)
is_small: boolTrue if rule length < SMALL_RULE (15 tokens)
is_tiny: boolTrue if rule length < TINY_RULE (6 tokens)
starts_with_license: boolTrue if the rule’s first token is “license”, “licence”, or “licensed”
ends_with_license: boolTrue if the rule’s last token is “license”, “licence”, or “licensed”
is_deprecated: boolWhether this rule is deprecated
spdx_license_key: Option<String>SPDX license identifier if available
other_spdx_license_keys: Vec<String>Alternative SPDX license identifiers (aliases)
Implementations§
Source§impl Rule
impl Rule
pub const fn kind(&self) -> RuleKind
pub const fn is_license_text(&self) -> bool
Sourcepub const fn is_license_notice(&self) -> bool
pub const fn is_license_notice(&self) -> bool
Returns true if this rule is a license notice pattern.
Note: This method is kept for API completeness and potential future use.
License matches cannot have is_license_notice - only rules can.
pub const fn is_license_reference(&self) -> bool
pub const fn is_license_tag(&self) -> bool
Sourcepub const fn is_license_intro(&self) -> bool
pub const fn is_license_intro(&self) -> bool
Returns true if this rule is a license introduction pattern.
Note: This method is kept for API completeness and potential future use.
pub const fn is_license_clue(&self) -> bool
Trait Implementations§
Source§impl Ord for Rule
impl Ord for Rule
Source§impl PartialOrd for Rule
impl PartialOrd for Rule
impl Eq for Rule
impl StructuralPartialEq for Rule
Auto Trait Implementations§
impl Freeze for Rule
impl RefUnwindSafe for Rule
impl Send for Rule
impl Sync for Rule
impl Unpin for Rule
impl UnsafeUnpin for Rule
impl UnwindSafe for Rule
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> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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