pub struct ErrorCode;Expand description
HTTP 状态码与业务错误码常量集
§使用示例
use tdm_server_rust::common::ErrorCode;
assert_eq!(ErrorCode::SUCCESS, 200);
assert_eq!(ErrorCode::LOGIN_REQUIRED, 401);§取值说明
| 常量 | 值 | HTTP 对应 | 说明 |
|---|---|---|---|
SUCCESS | 200 | 200 OK | 操作成功 |
SYSTEM_ERROR | 500 | 500 Internal Server Error | 系统内部错误 |
LOGIN_REQUIRED | 401 | 401 Unauthorized | 未登录或 token 过期 |
UNIQUE_VIOLATION | 1002 | 409 Conflict | 数据库唯一约束冲突 |
DOWNLOAD_UNAUTHENTIC | 1003 | 403 Forbidden | 下载权限不足 |
Implementations§
Source§impl ErrorCode
impl ErrorCode
Sourcepub const SYSTEM_ERROR: i32 = 500
pub const SYSTEM_ERROR: i32 = 500
系统错误
Sourcepub const LOGIN_REQUIRED: i32 = 401
pub const LOGIN_REQUIRED: i32 = 401
需要登录
Sourcepub const UNIQUE_VIOLATION: i32 = 1002
pub const UNIQUE_VIOLATION: i32 = 1002
唯一约束冲突
Sourcepub const DOWNLOAD_UNAUTHENTIC: i32 = 1003
pub const DOWNLOAD_UNAUTHENTIC: i32 = 1003
下载无权限
Auto Trait Implementations§
impl Freeze for ErrorCode
impl RefUnwindSafe for ErrorCode
impl Send for ErrorCode
impl Sync for ErrorCode
impl Unpin for ErrorCode
impl UnsafeUnpin for ErrorCode
impl UnwindSafe for ErrorCode
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request