pub struct LicenseValidator { /* private fields */ }Expand description
License key validator for offline validation
Implementations§
Source§impl LicenseValidator
impl LicenseValidator
Sourcepub fn validate_key(&self, license_key: &str) -> Result<LicenseInfo>
pub fn validate_key(&self, license_key: &str) -> Result<LicenseInfo>
Validate a license key
§Arguments
license_key- The license key to validate
§Returns
LicenseInfo if the license is valid, or an error
§Example
use alvan_lic::{LicenseGenerator, LicenseValidator};
let secret = "secret-key";
let generator = LicenseGenerator::new(secret);
let validator = LicenseValidator::new(secret);
let license = generator.generate_key(24).unwrap();
let info = validator.validate_key(&license).unwrap();
assert!(info.is_valid);Sourcepub fn validate_key_at_time(
&self,
license_key: &str,
current_time: DateTime<Utc>,
) -> Result<LicenseInfo>
pub fn validate_key_at_time( &self, license_key: &str, current_time: DateTime<Utc>, ) -> Result<LicenseInfo>
Validate a license key at a specific time (useful for testing)
Auto Trait Implementations§
impl Freeze for LicenseValidator
impl RefUnwindSafe for LicenseValidator
impl Send for LicenseValidator
impl Sync for LicenseValidator
impl Unpin for LicenseValidator
impl UnsafeUnpin for LicenseValidator
impl UnwindSafe for LicenseValidator
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