pub struct RateLimitResponse {
pub status_code: u16,
pub headers: RateLimitHeaders,
pub body: Value,
}Expand description
限流响应
封装被限流时的完整响应信息,包括状态码、头和响应体。
Fields§
§status_code: u16HTTP 状态码
headers: RateLimitHeaders响应头
body: ValueJSON 响应体
Implementations§
Source§impl RateLimitResponse
impl RateLimitResponse
Sourcepub fn rejected(
result: &RateLimitResult,
limit: u64,
strategy: RateLimitResponseStrategy,
) -> Self
pub fn rejected( result: &RateLimitResult, limit: u64, strategy: RateLimitResponseStrategy, ) -> Self
创建被限流的响应
result:限流结果(必须是 rejected)limit:窗口内最大请求数strategy:响应策略
Sourcepub fn allowed(result: &RateLimitResult, limit: u64) -> Self
pub fn allowed(result: &RateLimitResult, limit: u64) -> Self
创建允许通过的响应(仅包含头,无响应体)
Trait Implementations§
Source§impl Clone for RateLimitResponse
impl Clone for RateLimitResponse
Source§fn clone(&self) -> RateLimitResponse
fn clone(&self) -> RateLimitResponse
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RateLimitResponse
impl RefUnwindSafe for RateLimitResponse
impl Send for RateLimitResponse
impl Sync for RateLimitResponse
impl Unpin for RateLimitResponse
impl UnsafeUnpin for RateLimitResponse
impl UnwindSafe for RateLimitResponse
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