1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! 错误类型定义 / Error type definitions.
//!
//! 提供 crate 统一的错误类型 [`Error`] 和 [`Result`] 别名。
//! Provides the crate-wide error type [`Error`] and [`Result`] alias.
use Cow;
use Error;
/// tcpclient 的所有错误类型。
/// All error types for tcpclient.
///
/// 使用 [`thiserror`] 自动派生 `Display` 和 `std::error::Error`。
/// Uses [`thiserror`] to auto-derive `Display` and `std::error::Error`.
///
/// `SendError` 使用 [`Cow<'static, str>`]:静态消息零分配,动态消息才堆分配。
/// `SendError` uses [`Cow<'static, str>`]: zero-allocation for static messages,
/// heap allocation only for dynamic ones.
/// crate 统一的 `Result` 类型别名,默认错误类型为 [`Error`]。
/// Crate-wide `Result` type alias defaulting to [`Error`].
///
/// ```rust
/// use tcpclient::error::Result;
/// ```
pub type Result<T, E = Error> = Result;