pub struct RateLimits {
pub global_limit: RateLimit,
pub get_limits: HashMap<String, RateLimit>,
pub post_limits: HashMap<String, RateLimit>,
}Expand description
接口速度限制集合
Fields§
§global_limit: RateLimit全局限制
get_limits: HashMap<String, RateLimit>GET 请求限制
post_limits: HashMap<String, RateLimit>POST 请求限制
Implementations§
Source§impl RateLimits
impl RateLimits
Sourcepub fn get_limit(&self, method: &Method, path: &str) -> RateLimit
pub fn get_limit(&self, method: &Method, path: &str) -> RateLimit
获取指定请求方法和请求路径的限速信息,找不到返回 global 的限速信息 参数:
- method: 请求方法,GET or POST
- path: 请求路径
Sourcepub fn get_limit_mut(&mut self, method: &Method, path: &str) -> &mut RateLimit
pub fn get_limit_mut(&mut self, method: &Method, path: &str) -> &mut RateLimit
获取指定请求方法和请求路径的限速信息,找不到返回 global 的限速信息 参数:
- method: 请求方法,GET or POST
- path: 请求路径
Sourcepub fn update_limit(
&mut self,
method: &Method,
path: &str,
rate_limit: RateLimit,
)
pub fn update_limit( &mut self, method: &Method, path: &str, rate_limit: RateLimit, )
更新限速信息 参数:
- method: 请求方法,GET or POST
- path: 请求路径
- limit: 限速信息
Sourcepub fn update_from_headers(
&mut self,
method: &Method,
path: &str,
headers: &HeaderMap,
)
pub fn update_from_headers( &mut self, method: &Method, path: &str, headers: &HeaderMap, )
根据响应头更新限速信息
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RateLimits
impl RefUnwindSafe for RateLimits
impl Send for RateLimits
impl Sync for RateLimits
impl Unpin for RateLimits
impl UnwindSafe for RateLimits
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