知识卡片

普通读书笔记卡 · 6074.f.1.a

零复制解析绑定输入有效期

理解等级:中级

TLV按类型、长度和值组织数据;借用切片解析能避免复制,但返回值不能活过输入,输入缓冲也不能在借用仍用时被重写。解析时需先检查头部与长度,再形成切片。零复制适合短时处理,不自动适合长期保存。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Chapter 3. Concepts Data Structures and Allocation · 查看原书依据

      type-length-value (TLV) structures where data is transferred in the following format: One byte describing the type of the value (stored in the type_code field here)10 One byte describing the length of the value in bytes (used here to create a slice of the specified length) Followed by the specified number of bytes for the value (stored in the value field): /

    参考来源

    - 位置:《Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)》第3章《Data Structures and Allocation》(spine7;extracted/Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)/_epub-src/OEBPS/ch03.html;u110-ch03-049)。 - 结论依据:原文在“type-length-value”附近的定义、例子或代码支撑本卡核心说明:TLV按类型、长度和值组织数据;借用切片解析能避免复制,但返回值不能活过输入,输入缓冲也不能在借用仍用时被重写。边界按已读前提解释;示例未执行。 - 原始内容:type-length-value (TLV) structures where data is transferred in the following format: One byte describing the type of the value (stored in the type_code field here)10 One byte describing the length of the value in bytes (used here to create a slice of the specified length) Followed by the specified number of bytes for the value (stored in the value field): /