Skip to main content

CodeMsg

Trait CodeMsg 

Source
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§

Source

fn err_code(self) -> AppErrCode

将自身转换为归一化的 AppErrCode

Provided Methods§

Source

fn domain(self) -> &'static str

Source

fn code(self) -> i32

Source

fn message(self) -> &'static str

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl CodeMsg for tx_error::error::DiErr

Source§

impl CodeMsg for tx_di_core::error::DiErr