2 unstable releases
0.2.0 | May 15, 2020 |
---|---|
0.1.0 | May 11, 2020 |
#5 in #group-id
8KB
80 lines
Token Manager
This crate provides useful abstractions for managing VK tokens.
Install
[dependencies]
vk-token-manager = "0.2.0"
Using
Checkout /examples
directory for more examples.
use token_manager::{TokenManager, ManageTokens};
use token_manager::{GroupId, SimpleToken, Token};
let mut manager = TokenManager::new(); // create token manager
// put (boxed) token into.
manager.add_token(GroupId::new(123), Box::new(SimpleToken::new(Token::new("my-token".into()))));
let result = async {
// get token by id
let tok = manager.get_by_id(GroupId::new(123)).await;
assert_eq!(tok, Some(&Token::new("my-token".into())));
};
lib.rs
:
Crate for managing tokens for VK bots! It provides a few abstractions for doing it.
Example
use token_manager::{TokenManager, ManageTokens};
use token_manager::{GroupId, SimpleToken, Token};
let mut manager = TokenManager::new(); // create token manager
// put (boxed) token into.
manager.add_token(GroupId::new(123), Box::new(SimpleToken::new(Token::new("my-token".into()))));
let result = async {
// get token by id
let tok = manager.get_by_id(GroupId::new(123)).await;
assert_eq!(tok, Some(&Token::new("my-token".into())));
};
Dependencies
~255–710KB
~17K SLoC