Skip to content

Commit 5b4eea8

Browse files
committed
docs(readme): update version compatibility and Zig 0.16 support notes
- add comprehensive version compatibility table for Zig - document Zig 0.16 standard library changes and compatibility layer - update README and Chinese README with new version support details - explain internal compatibility mechanism for different Zig versions
1 parent f942c1d commit 5b4eea8

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,18 @@ An article introducing it: [Zig Msgpack](https://blog.nvimer.org/2025/05/03/zig-
1616

1717
## Installation
1818

19-
> For Zig 0.13 and older versions, please use version `0.0.6` of this library.
19+
### Version Compatibility
2020

21-
For Zig `0.14.0` and `nightly`, follow these steps:
21+
| Zig Version | Library Version | Status |
22+
|-------------|----------------|---------|
23+
| 0.13 and older | 0.0.6 | Legacy support |
24+
| 0.14.0 | Current | ✅ Fully supported |
25+
| 0.15.x | Current | ✅ Fully supported |
26+
| 0.16.0-dev (nightly) | Current | ✅ Fully supported |
27+
28+
> **Note:** For Zig 0.13 and older versions, please use version `0.0.6` of this library.
29+
30+
For Zig `0.14.0`, `0.15.x`, and `0.16.0-dev`, follow these steps:
2231

2332
1. **Add as a dependency:**
2433
Add the library to your `build.zig.zon` file. You can fetch a specific commit or branch.
@@ -152,6 +161,18 @@ const uint_result = int_payload.getUint() catch |err| switch (err) {
152161
- **`msgpack.Pack`**: The main struct for packing and unpacking MessagePack data. It is initialized with read and write contexts.
153162
- **`msgpack.Payload`**: A union that represents any MessagePack type. It provides methods for creating and interacting with different data types (e.g., `mapPayload`, `strToPayload`, `mapGet`).
154163
164+
## Implementation Notes
165+
166+
### Zig 0.16 Compatibility
167+
168+
Starting from Zig 0.16, the standard library underwent significant changes to the I/O subsystem. The `std.io.FixedBufferStream` was removed as part of a broader redesign. This library includes a compatibility layer (`src/compat.zig`) that:
169+
170+
- Provides a `BufferStream` implementation for Zig 0.16+ that mimics the behavior of the old `FixedBufferStream`
171+
- Uses conditional compilation to maintain backward compatibility with Zig 0.14 and 0.15
172+
- Ensures all existing functionality works seamlessly across different Zig versions
173+
174+
This means you can use the same API regardless of your Zig version, and the library will handle the differences internally.
175+
155176
## Testing
156177
157178
To run the unit tests for this library, use the following command:

README_CN.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,18 @@ Zig 编程语言的 MessagePack 实现。此库提供了一种简单高效的方
1616

1717
## 安装
1818

19-
> 对于 Zig 0.13 及更早版本,请使用本库的 `0.0.6` 版本。
19+
### 版本兼容性
2020

21-
对于 Zig `0.14.0``nightly` 版本,请按以下步骤操作:
21+
| Zig 版本 | 库版本 | 状态 |
22+
|-------------|----------------|---------|
23+
| 0.13 及更早版本 | 0.0.6 | 旧版支持 |
24+
| 0.14.0 | 当前版本 | ✅ 完全支持 |
25+
| 0.15.x | 当前版本 | ✅ 完全支持 |
26+
| 0.16.0-dev (nightly) | 当前版本 | ✅ 完全支持 |
27+
28+
> **注意**: 对于 Zig 0.13 及更早版本,请使用本库的 `0.0.6` 版本。
29+
30+
对于 Zig `0.14.0``0.15.x``0.16.0-dev` 版本,请按以下步骤操作:
2231

2332
1. **添加为依赖项**:
2433
将库添加到您的 `build.zig.zon` 文件中。您可以获取特定的提交或分支。
@@ -152,6 +161,18 @@ const uint_result = int_payload.getUint() catch |err| switch (err) {
152161
- **`msgpack.Pack`**: 用于打包和解包 MessagePack 数据的主要结构体。使用读写上下文进行初始化。
153162
- **`msgpack.Payload`**: 表示任何 MessagePack 类型的联合体。提供创建和与不同数据类型交互的方法(例如,`mapPayload``strToPayload``mapGet`)。
154163

164+
## 实现说明
165+
166+
### Zig 0.16 兼容性
167+
168+
从 Zig 0.16 开始,标准库的 I/O 子系统经历了重大变更。作为更广泛重新设计的一部分,`std.io.FixedBufferStream` 被移除。本库包含一个兼容层(`src/compat.zig`),它:
169+
170+
- 为 Zig 0.16+ 提供了一个 `BufferStream` 实现,模拟旧版 `FixedBufferStream` 的行为
171+
- 使用条件编译来保持与 Zig 0.14 和 0.15 的向后兼容性
172+
- 确保所有现有功能在不同 Zig 版本间无缝工作
173+
174+
这意味着无论您使用哪个 Zig 版本,都可以使用相同的 API,库会在内部处理差异。
175+
155176
## 测试
156177

157178
要运行此库的单元测试,请使用以下命令:

0 commit comments

Comments
 (0)