ValidationResult

Struct ValidationResult 

Source
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: bool

Whether 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

Source

pub fn success(payload: LicensePayload) -> Self

Creates a successful validation result.

Source

pub fn failure(failures: Vec<ValidationFailure>) -> Self

Creates a failed validation result with the given failures.

Source

pub fn add_failure(&mut self, failure: ValidationFailure)

Adds a failure to the result and marks it as invalid.

Source

pub fn is_active(&self) -> bool

Returns true if the license is valid and not expired.

Source

pub fn days_remaining(&self) -> Option<i64>

Returns the number of days remaining until expiration. Returns None if the license never expires.

Source

pub fn is_feature_allowed(&self, feature: &str) -> bool

Checks if a specific feature is allowed by the validated license.

Source

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);
// }
Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn get_i64_or(&self, key: &str, default: i64) -> i64

Gets an i64 value from the license metadata, or returns a default.

Source

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.

Source

pub fn get_u64_or(&self, key: &str, default: u64) -> u64

Gets a u64 value from the license metadata, or returns a default.

Source

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.

Source

pub fn get_f64_or(&self, key: &str, default: f64) -> f64

Gets an f64 value from the license metadata, or returns a default.

Source

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.

Source

pub fn get_bool_or(&self, key: &str, default: bool) -> bool

Gets a boolean value from the license metadata, or returns a default.

Source

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.

Source

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.

Source

pub fn get_object(&self, key: &str) -> Option<&Map<String, Value>>

Gets an object value from the license metadata.

Returns None if validation failed, the key doesn’t exist, or the value is not an object.

Source

pub fn has_key(&self, key: &str) -> bool

Checks if a key exists in the license metadata.

Returns false if validation failed or no metadata is present.

Trait Implementations§

Source§

impl Clone for ValidationResult

Source§

fn clone(&self) -> ValidationResult

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ValidationResult

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V