pub struct KeygenProvider { /* private fields */ }Expand description
Keygen-backed LicenseProvider. The account id is a public UUID; no secrets here
(clients ship no admin token — license-key auth only).
Implementations§
Source§impl KeygenProvider
impl KeygenProvider
pub fn new(account_id: impl Into<String>, api_base: impl Into<String>) -> Self
Sourcepub fn from_config(config: &LicenseConfig) -> Self
pub fn from_config(config: &LicenseConfig) -> Self
Build from the shared LicenseConfig.
Examples found in repository?
examples/headless.rs (line 31)
15fn main() {
16 let storage = StorageConfig {
17 path: std::env::temp_dir().join("rustify-demo-license.env"),
18 dev_shadow: None,
19 env_key_var: Some("RUSTIFY_DEMO_KEY".into()),
20 };
21 let config = LicenseConfig {
22 // Your Keygen account id (a public UUID). Set it here or via KEYGEN_ACCOUNT.
23 account_id: std::env::var("KEYGEN_ACCOUNT")
24 .unwrap_or_else(|_| "YOUR_KEYGEN_ACCOUNT_ID".into()),
25 api_base: "https://api.keygen.sh/v1".into(),
26 grace_secs: 14 * 24 * 60 * 60,
27 storage,
28 buy_url: "https://example.com/#pricing".into(),
29 };
30
31 let provider = KeygenProvider::from_config(&config);
32 let mut state = LicenseState::load(&config.storage);
33 println!("fingerprint: {}", state.fingerprint);
34
35 if state.key.trim().is_empty() {
36 println!("no key set — export RUSTIFY_DEMO_KEY=<license-key> to test → status: Locked");
37 return;
38 }
39
40 let status = check_blocking(&config, &provider, &mut state, |line| println!(" … {line}"));
41 println!("status: {status:?}");
42}Trait Implementations§
Auto Trait Implementations§
impl Forget for KeygenProvider
impl Freeze for KeygenProvider
impl RefUnwindSafe for KeygenProvider
impl Send for KeygenProvider
impl Sync for KeygenProvider
impl Unpin for KeygenProvider
impl UnsafeUnpin for KeygenProvider
impl UnwindSafe for KeygenProvider
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