pub struct ValidatedLicense { /* private fields */ }Expand description
A validated license guard that ensures the license was verified before access.
This pattern makes it impossible to access license data without first validating it.
The only way to construct a ValidatedLicense is through the validation methods,
which guarantees the license has been cryptographically verified.
§Example
ⓘ
use licenz_core::{require_license, LicenseVerifier};
// This is the ONLY way to get license data
let license = require_license("license.lic", PUBLIC_KEY)?;
// Now you can safely access the data
println!("Licensed to: {}", license.customer_id);
if license.has_feature("premium") {
enable_premium();
}Implementations§
Source§impl ValidatedLicense
impl ValidatedLicense
Sourcepub fn data(&self) -> &LicenseData
pub fn data(&self) -> &LicenseData
Get the underlying license data
Sourcepub fn validated_at(&self) -> DateTime<Utc>
pub fn validated_at(&self) -> DateTime<Utc>
Get when this license was validated
Sourcepub fn has_feature(&self, feature: &str) -> bool
pub fn has_feature(&self, feature: &str) -> bool
Check if a feature is enabled
Sourcepub fn days_remaining(&self) -> i64
pub fn days_remaining(&self) -> i64
Get days remaining
Sourcepub fn into_inner(self) -> SignedLicense
pub fn into_inner(self) -> SignedLicense
Get the raw signed license (for serialization, etc.)
Methods from Deref<Target = LicenseData>§
Sourcepub fn has_feature(&self, feature: &str) -> bool
pub fn has_feature(&self, feature: &str) -> bool
Check if a feature is enabled
Sourcepub fn days_remaining(&self) -> i64
pub fn days_remaining(&self) -> i64
Get remaining days until expiration
Sourcepub fn is_time_valid(&self) -> bool
pub fn is_time_valid(&self) -> bool
Check if the license is currently in its valid time window
Trait Implementations§
Source§impl Clone for ValidatedLicense
impl Clone for ValidatedLicense
Source§fn clone(&self) -> ValidatedLicense
fn clone(&self) -> ValidatedLicense
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ValidatedLicense
impl Debug for ValidatedLicense
Auto Trait Implementations§
impl Freeze for ValidatedLicense
impl RefUnwindSafe for ValidatedLicense
impl Send for ValidatedLicense
impl Sync for ValidatedLicense
impl Unpin for ValidatedLicense
impl UnsafeUnpin for ValidatedLicense
impl UnwindSafe for ValidatedLicense
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
Mutably borrows from an owned value. Read more