pub struct Jwt { /* private fields */ }Implementations§
Source§impl Jwt
impl Jwt
Sourcepub fn payload(&mut self, sub: &str, aud: &str, custom: JsonValue) -> &mut Self
pub fn payload(&mut self, sub: &str, aud: &str, custom: JsonValue) -> &mut Self
token信息
- sub 主题
- aud 受众
- custom 自定义内容
Sourcepub fn verify(token: &str, key: &str) -> bool
pub fn verify(token: &str, key: &str) -> bool
验证
Examples found in repository?
examples/jwt.rs (line 18)
4fn main() {
5 // let mut data = jwt::Jwt::default("admin");
6 // let data = data.payload("2222", "1111", object! {
7 // "name":"123123"
8 // });
9 // data.nbf_exp(0, 0);
10 // let token = data.sign("123456");
11 // let data = jwt::Jwt::verify(token.as_str().clone(), "123456");
12 // println!("{}", data);
13 // let data = jwt::Jwt::info(token.as_str().clone());
14 // println!("{}", data);
15
16 let token = "12313";
17
18 let data = jwt::Jwt::verify(token.clone(), "123456");
19 println!("{}",data);
20}Auto Trait Implementations§
impl Freeze for Jwt
impl RefUnwindSafe for Jwt
impl Send for Jwt
impl Sync for Jwt
impl Unpin for Jwt
impl UnwindSafe for Jwt
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