pub trait CodeMsg:
Debug
+ Display
+ Copy
+ Sync
+ Send
+ 'static {
// Required method
fn err_code(self) -> AppErrCode;
// Provided methods
fn domain(self) -> &'static str { ... }
fn code(self) -> i32 { ... }
fn message(self) -> &'static str { ... }
}Expand description
错误码转换 trait — 连接业务错误枚举与统一 AppError 的桥梁。
通过 #[derive(CodeMsg)] 宏自动生成实现,业务层无需手写。
Required Methods§
Sourcefn err_code(self) -> AppErrCode
fn err_code(self) -> AppErrCode
将自身转换为归一化的 AppErrCode 值
Provided Methods§
fn domain(self) -> &'static str
fn code(self) -> i32
fn message(self) -> &'static str
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".