docs(irtt-proto): add runnable doctests for public API
Add executable doctests documenting the consumer-facing contract of irtt-proto: the directional request encode/decode/verify split, Params construction and round-trip, omitted-vs-explicit-zero presence, open and echo reply round trips, packet length calculation, and HMAC verification. No conventional tests are migrated: every existing irtt-proto test exercises wire vectors, flag matrices, malformed input, layout rules, HMAC error behavior, or encode/decode round trips, which the crate's AGENTS.md treats as durable compatibility coverage rather than documentation cleanup targets.
This commit is contained in:
8 files changed
+236
No files matched your search
@@ -1,3 +1,19 @@
|
||||
//! Variable-length integer encoding for IRTT wire values.
|
||||
//!
|
||||
//! Tags use an unsigned base-128 varint ([`encode_uvarint`]), and signed
|
||||
//! integers (such as parameter values) use the same encoding after a zigzag
|
||||
//! transform ([`encode_varint`]), which keeps small negative numbers compact.
|
||||
//!
|
||||
//! # Example
|
||||
//!
|
||||
//! ```
|
||||
//! use irtt_proto::varint::{decode_varint, encode_varint};
|
||||
//!
|
||||
//! let mut out = Vec::new();
|
||||
//! encode_varint(1_000_000_000, &mut out);
|
||||
//! assert_eq!(decode_varint(&out).unwrap(), (1_000_000_000, out.len()));
|
||||
//! ```
|
||||
|
||||
use crate::{ProtoError, Result};
|
||||
|
||||
pub fn encode_uvarint(mut value: u64, out: &mut Vec<u8>) {
|
||||
|
||||
Reference in new issue
Block a user