pub struct ValidationResult {
pub is_valid: bool,
pub payload: Option<LicensePayload>,
pub failures: Vec<ValidationFailure>,
pub time_remaining: Option<Duration>,
pub allowed_features: Option<HashSet<String>>,
pub denied_features: Option<HashSet<String>>,
}Expand description
The result of validating a license.
This structure provides comprehensive information about the validation outcome, including whether it succeeded and detailed status information.
Fields§
§is_valid: boolWhether the license is valid.
payload: Option<LicensePayload>The validated license payload (only present if signature was valid).
failures: Vec<ValidationFailure>List of validation failures encountered. Empty if validation succeeded.
time_remaining: Option<Duration>Time remaining until the license expires.
None if the license never expires or is already expired.
allowed_features: Option<HashSet<String>>List of features that are allowed by this license. Only populated if validation succeeded.
denied_features: Option<HashSet<String>>List of features that are denied by this license. Only populated if validation succeeded.
Implementations§
Source§impl ValidationResult
impl ValidationResult
Sourcepub fn success(payload: LicensePayload) -> Self
pub fn success(payload: LicensePayload) -> Self
Creates a successful validation result.
Sourcepub fn failure(failures: Vec<ValidationFailure>) -> Self
pub fn failure(failures: Vec<ValidationFailure>) -> Self
Creates a failed validation result with the given failures.
Sourcepub fn add_failure(&mut self, failure: ValidationFailure)
pub fn add_failure(&mut self, failure: ValidationFailure)
Adds a failure to the result and marks it as invalid.
Sourcepub fn days_remaining(&self) -> Option<i64>
pub fn days_remaining(&self) -> Option<i64>
Returns the number of days remaining until expiration.
Returns None if the license never expires.
Sourcepub fn is_feature_allowed(&self, feature: &str) -> bool
pub fn is_feature_allowed(&self, feature: &str) -> bool
Checks if a specific feature is allowed by the validated license.
Sourcepub fn get_value(&self, key: &str) -> Option<&Value>
pub fn get_value(&self, key: &str) -> Option<&Value>
Gets a custom value from the license metadata by key.
Returns None if validation failed, the key doesn’t exist,
or if no metadata is present.
§Example
use rust_license_key::prelude::*;
// After validating:
// if let Some(value) = result.get_value("max_users") {
// println!("Max users: {}", value);
// }Sourcepub fn get_value_or<'a>(&'a self, key: &str, default: &'a Value) -> &'a Value
pub fn get_value_or<'a>(&'a self, key: &str, default: &'a Value) -> &'a Value
Gets a custom value from the license metadata, or returns a default value.
Sourcepub fn get_string(&self, key: &str) -> Option<&str>
pub fn get_string(&self, key: &str) -> Option<&str>
Gets a string value from the license metadata.
Returns None if validation failed, the key doesn’t exist,
or the value is not a string.
Sourcepub fn get_string_or<'a>(&'a self, key: &str, default: &'a str) -> &'a str
pub fn get_string_or<'a>(&'a self, key: &str, default: &'a str) -> &'a str
Gets a string value from the license metadata, or returns a default.
Sourcepub fn get_i64(&self, key: &str) -> Option<i64>
pub fn get_i64(&self, key: &str) -> Option<i64>
Gets an i64 value from the license metadata.
Returns None if validation failed, the key doesn’t exist,
or the value is not a number.
Sourcepub fn get_i64_or(&self, key: &str, default: i64) -> i64
pub fn get_i64_or(&self, key: &str, default: i64) -> i64
Gets an i64 value from the license metadata, or returns a default.
Sourcepub fn get_u64(&self, key: &str) -> Option<u64>
pub fn get_u64(&self, key: &str) -> Option<u64>
Gets a u64 value from the license metadata.
Returns None if validation failed, the key doesn’t exist,
or the value is not a positive number.
Sourcepub fn get_u64_or(&self, key: &str, default: u64) -> u64
pub fn get_u64_or(&self, key: &str, default: u64) -> u64
Gets a u64 value from the license metadata, or returns a default.
Sourcepub fn get_f64(&self, key: &str) -> Option<f64>
pub fn get_f64(&self, key: &str) -> Option<f64>
Gets an f64 value from the license metadata.
Returns None if validation failed, the key doesn’t exist,
or the value is not a number.
Sourcepub fn get_f64_or(&self, key: &str, default: f64) -> f64
pub fn get_f64_or(&self, key: &str, default: f64) -> f64
Gets an f64 value from the license metadata, or returns a default.
Sourcepub fn get_bool(&self, key: &str) -> Option<bool>
pub fn get_bool(&self, key: &str) -> Option<bool>
Gets a boolean value from the license metadata.
Returns None if validation failed, the key doesn’t exist,
or the value is not a boolean.
Sourcepub fn get_bool_or(&self, key: &str, default: bool) -> bool
pub fn get_bool_or(&self, key: &str, default: bool) -> bool
Gets a boolean value from the license metadata, or returns a default.
Sourcepub fn get_array(&self, key: &str) -> Option<&Vec<Value>>
pub fn get_array(&self, key: &str) -> Option<&Vec<Value>>
Gets an array value from the license metadata.
Returns None if validation failed, the key doesn’t exist,
or the value is not an array.
Sourcepub fn get_string_array(&self, key: &str) -> Option<Vec<&str>>
pub fn get_string_array(&self, key: &str) -> Option<Vec<&str>>
Gets a string array from the license metadata.
Returns None if validation failed, the key doesn’t exist,
or the value is not an array.
Trait Implementations§
Source§impl Clone for ValidationResult
impl Clone for ValidationResult
Source§fn clone(&self) -> ValidationResult
fn clone(&self) -> ValidationResult
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more