pub struct WxDefaultConfig {
pub app_id: String,
pub secret: String,
pub stable_access_token: bool,
pub auto_refresh: bool,
pub http_proxy_host: Option<String>,
pub http_proxy_port: Option<u16>,
/* private fields */
}Expand description
默认内存配置存储实现。
对应 Java Wx*DefaultConfigImpl 的内存语义:token 缓存 + 过期判断 + 锁。
业务模块可用组合方式继承此实现并扩展自身字段。
Fields§
§app_id: String§secret: String§stable_access_token: bool是否使用稳定版 token 接口
auto_refresh: booltoken 过期自动刷新
http_proxy_host: Option<String>代理主机
http_proxy_port: Option<u16>代理端口
Implementations§
Trait Implementations§
Source§impl Debug for WxDefaultConfig
impl Debug for WxDefaultConfig
Source§impl WxConfigStorage for WxDefaultConfig
impl WxConfigStorage for WxDefaultConfig
Source§fn access_token(&self) -> Option<String>
fn access_token(&self) -> Option<String>
返回当前缓存的 access token。
Source§fn is_access_token_expired(&self) -> bool
fn is_access_token_expired(&self) -> bool
判断 access token 是否已过期。
Source§fn expire_access_token(&self)
fn expire_access_token(&self)
强制将 access token 过期掉。
Source§fn update_access_token(&self, access_token: &str, expires_in_seconds: i32)
fn update_access_token(&self, access_token: &str, expires_in_seconds: i32)
更新 access token(线程安全)。 Read more
Source§fn access_token_lock(&self) -> Arc<AsyncMutex<()>> ⓘ
fn access_token_lock(&self) -> Arc<AsyncMutex<()>> ⓘ
返回 access token 锁(多线程只刷新一次语义)。
Source§fn is_stable_access_token(&self) -> bool
fn is_stable_access_token(&self) -> bool
是否使用稳定版 access token 接口(公众号稳定版)。
Source§fn auto_refresh_token(&self) -> bool
fn auto_refresh_token(&self) -> bool
token 过期时是否自动刷新(默认 true)。
Source§fn http_proxy_host(&self) -> Option<&str>
fn http_proxy_host(&self) -> Option<&str>
返回代理主机(
None 为不使用代理)。Source§fn http_proxy_port(&self) -> Option<u16>
fn http_proxy_port(&self) -> Option<u16>
返回代理端口。
Source§fn is_ticket_expired(&self, _ticket_type: TicketType) -> bool
fn is_ticket_expired(&self, _ticket_type: TicketType) -> bool
判断指定类型的 ticket 是否已过期。
Source§fn update_ticket(
&self,
_ticket_type: TicketType,
_ticket: &str,
_expires_in_seconds: i32,
)
fn update_ticket( &self, _ticket_type: TicketType, _ticket: &str, _expires_in_seconds: i32, )
更新指定类型的 ticket(线程安全)。
Source§fn ticket_lock(&self, _ticket_type: TicketType) -> Arc<AsyncMutex<()>> ⓘ
fn ticket_lock(&self, _ticket_type: TicketType) -> Arc<AsyncMutex<()>> ⓘ
返回指定类型 ticket 的锁(对应 Java
getTicketLock(TicketType) 按类型分配锁)。Source§fn expire_ticket(&self, _ticket_type: TicketType)
fn expire_ticket(&self, _ticket_type: TicketType)
强制将指定类型的 ticket 过期掉(对应 Java
expireTicket)。Auto Trait Implementations§
impl !Freeze for WxDefaultConfig
impl !RefUnwindSafe for WxDefaultConfig
impl !UnwindSafe for WxDefaultConfig
impl Send for WxDefaultConfig
impl Sync for WxDefaultConfig
impl Unpin for WxDefaultConfig
impl UnsafeUnpin for WxDefaultConfig
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