pub struct ErrorBuilder { /* private fields */ }Expand description
统一的错误构建器,避免直接依赖枚举内部字段
Implementations§
Source§impl ErrorBuilder
impl ErrorBuilder
Sourcepub fn new(kind: BuilderKind) -> Self
pub fn new(kind: BuilderKind) -> Self
创建指定类型的错误构建器
Sourcepub fn policy(self, policy: RetryPolicy) -> Self
pub fn policy(self, policy: RetryPolicy) -> Self
设置重试策略
Sourcepub fn request_id(self, req: impl Into<String>) -> Self
pub fn request_id(self, req: impl Into<String>) -> Self
设置请求 ID
Sourcepub fn user_message(self, msg: impl Into<String>) -> Self
pub fn user_message(self, msg: impl Into<String>) -> Self
设置用户友好的错误消息
Sourcepub fn reset_after(self, reset: Duration) -> Self
pub fn reset_after(self, reset: Duration) -> Self
设置限流重置时间
Sourcepub fn retry_after(self, retry_after: Duration) -> Self
pub fn retry_after(self, retry_after: Duration) -> Self
设置重试等待时间
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ErrorBuilder
impl !RefUnwindSafe for ErrorBuilder
impl Send for ErrorBuilder
impl Sync for ErrorBuilder
impl Unpin for ErrorBuilder
impl UnsafeUnpin for ErrorBuilder
impl !UnwindSafe for ErrorBuilder
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