| Crates.io | leb128rs |
| lib.rs | leb128rs |
| version | 1.0.0 |
| created_at | 2026-01-11 18:55:40.122871+00 |
| updated_at | 2026-01-11 18:55:40.122871+00 |
| description | An implementation of LEB128 for integral types of bit-widths 16, 32, 64 and 128 as well as size types. |
| homepage | |
| repository | https://github.com/quirxmode/leb128rs |
| max_upload_size | |
| id | 2036223 |
| size | 38,297 |
This crate provides LEB128 serialization and deserialization routines for the following types:
u16u32u64u128usizei16i32i64i128isizeThere are no functions for u8 and i8 as actual LEB128 encoding would never save space. If there is a need to encode these types, let me know.
The deserialization functions
If there is demand for a pedantic (and thus, slower) deserialization variant, let me know.
Commonly agreed-upon conversions can be found in
624485: 0xE5 0x8E 0x26-123456: 0xC0 0xBB 0x782: 0x02127: 0x7f128: 0x80 0x01129: 0x81 0x01130: 0x82 0x0112857: 0xB9 0x642: 0x02-2: 0x7E127: 0xFF 0x00-127: 0x81 0x7F128: 0x80 0x01-128: 0x80 0x7F129: 0x81 0x01-129: 0xFF 0x7EThe default unit tests also test the full range of
u16,i16,as well as