Expand description
§afastdata
高性能二进制序列化/反序列化库,通过 derive 宏为 Rust 类型自动生成序列化代码。
A high-performance binary serialization/deserialization library that automatically generates serialization code for Rust types via derive macros.
§编码规则 / Encoding Rules
| 类型 / Type | 编码方式 / Encoding |
|---|---|
i8, u8 | 1 字节 little-endian / 1 byte little-endian |
i16, u16 | 2 字节 little-endian / 2 bytes little-endian |
i32, u32 | 4 字节 little-endian / 4 bytes little-endian |
i64, u64 | 8 字节 little-endian / 8 bytes little-endian |
i128, u128 | 16 字节 little-endian / 16 bytes little-endian |
f32 | 4 字节 IEEE 754 / 4 bytes IEEE 754 |
f64 | 8 字节 IEEE 754 / 8 bytes IEEE 754 |
bool | 1 字节,0x00=false,0x01=true / 1 byte, 0x00=false, 0x01=true |
String | 长度前缀 (LenInt) + UTF-8 字节 / Length prefix (LenInt) + UTF-8 bytes |
Vec<T> | 长度前缀 (LenInt) + 逐元素编码 / Length prefix (LenInt) + element-wise encoding |
Option<T> | 标记字节 (0x00=None, 0x01=Some) + 数据(仅 Some 时)/ Tag byte (0x00=None, 0x01=Some) + data (only when Some) |
[T; N] | 逐元素编码,无长度前缀 / Element-wise encoding, no length prefix |
&str | 长度前缀 (LenInt) + UTF-8 字节(仅序列化)/ Length prefix (LenInt) + UTF-8 bytes (serialize only) |
§长度前缀类型 / Length Prefix Type
默认使用 u32 作为长度前缀(最大 4GB),可通过启用 len-u64 feature 切换为 u64。
By default, u32 is used as the length prefix (max 4GB). Enable the len-u64
feature to switch to u64.
Structs§
- Error
- afastdata 的核心错误类型。
- Validate
Error - 用于更丰富错误构造的验证错误类型。
Enums§
- Error
Kind - 列举 afastdata 可能产生的错误类型。
Constants§
- LEN_
INT_ SIZE - 长度前缀类型的字节大小(
u32为 4,u64为 8)。
Traits§
- AFast
Deserialize - 反序列化 trait,为类型提供从字节数组还原的能力。
- AFast
Serialize - 序列化 trait,为类型提供转换为字节数组的能力。
Type Aliases§
- LenInt
- 长度前缀使用的整数类型。默认为
u32,启用len-u64feature 后为u64。
Derive Macros§
- AFast
Deserialize - Re-export derive 宏。
- AFast
Serialize - Re-export derive 宏。