Struct jiguang_certification::JiGuang[][src]

pub struct JiGuang<'r> { /* fields omitted */ }

极光构造器

Implementations

impl<'r> JiGuang<'r>[src]

pub fn new(app_key: &'r str, master_secret: &'r str) -> Self[src]

初始化极光

使用极光控制台获取的AppKey和MasterSecret初始化

Example

use jiguang_certification::JiGuang;

let jiguang = JiGuang::new("12345", "qwerty");

assert_eq!(jiguang, JiGuang { app_key: "12345", master_secret: "qwerty"});

pub async fn login_token_verify(
    &self,
    login_token: &str,
    private_key: &PrivateKey
) -> Result<String, Error>
[src]

提交loginToken,验证后返回手机号码

  • loginToken: 认证SDK获取到的loginToken
  • private_key: 验证手机号码和token是否一致的请求类型

Example

use jiguang_certification::JiGuang;
use jiguang_certification::PrivateKey;

let s = r#"
-----BEGIN PRIVATE KEY-----
MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBALx3lux8fiSk8+2f
au7sdQtaAu7GGEIr5juBy6nXq4K+73rN8HPMxEpmg6SnGMFzDL+UlUH9JoRuW7D4
qi7mHmtiOhLXbTSNpPPM/It9gHXYDMV1bD4Z6l3gafttaoim1JGfCqlXQAjzVm1u
-----END PRIVATE KEY-----
"#;

let private_key = PrivateKey::from_str(s).unwrap();

let jiguang = JiGuang::new("12345", "qwerty");

let phone = jiguang.login_token_verify("login_token", &private_key).await.unwrap();

println!("{}", phone);

pub async fn verify(
    &self,
    token: &str,
    phone: &str,
    verify_type: VerifyType
) -> Result<bool, Error>
[src]

验证token和手机号码是否一致

  • token: 运营商下发的token
  • phone: 待认证的手机号码
  • verify_type: 验证手机号码和token是否一致的请求类型

Example

use jiguang_certification::JiGuang;
use jiguang_certification::VerifyType;

let jiguang = JiGuang::new("12345", "qwerty");

let result = jiguang.verify("token", "phone", VerifyType::APP).await.unwrap();

assert!(result);

Trait Implementations

impl<'r> Debug for JiGuang<'r>[src]

impl<'r> PartialEq<JiGuang<'r>> for JiGuang<'r>[src]

impl<'r> StructuralPartialEq for JiGuang<'r>[src]

Auto Trait Implementations

impl<'r> RefUnwindSafe for JiGuang<'r>

impl<'r> Send for JiGuang<'r>

impl<'r> Sync for JiGuang<'r>

impl<'r> Unpin for JiGuang<'r>

impl<'r> UnwindSafe for JiGuang<'r>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,