Expand description
bufkit
no_std
-friendly, memory-backed buffer toolkit designed for Sans-I/O style encoding and decoding.
Provides Chunk
(read-only view), ChunkMut
(mutable view), and helpers for explicit, convenient bounds-checked access.
§Overview
bufkit is a small, focused toolkit for working with in-memory buffers in a predictable, controlled way.
It’s Sans-I/O friendly — meaning it’s easy to integrate into network protocol parsers, database engines, binary file format decoders/encoders, and embedded systems that follow the Sans-I/O design pattern — but it doesn’t implement any I/O itself.
§Features
- Predictable memory usage – operates directly on memory you provide, no hidden allocations.
- Explicit error handling – choose panicking,
Option
, or detailedResult
with requested vs. available byte counts. - Segmented views – create independent
Chunk
/ChunkMut
views into the same buffer. - Offset reads/writes – operate at arbitrary positions without unsafe pointer math.
- Embedded friendly -
no_std
&no_alloc
ready – works in embedded and constrained environments. - Retry-friendly –
try_*
methods enable robust partial read/write handling.
§Installation
[dependencies]
bufkit = "0.5"
§Feature Flags
Feature | Default? | Description |
---|---|---|
std | Yes | Enables std integration |
alloc | No | Enables heap-allocated buffer support |
varint | No | LEB128 encoding & decoding |
bytes_1 | No | Enable integration with bytes 1.x |
§Alternatives
bytes::{Buf, BufMut}
: Buffer traits for the bytes may or may not be stored in contiguous memory.buffer-trait
: ABuffer
trait for reading into uninitialized buffers.
§License
bufkit
is under the terms of both the MIT license and the
Apache License (Version 2.0).
See LICENSE-APACHE, LICENSE-MIT for details.
Copyright (c) 2025 Al Liu.
Modules§
- error
- Errors buffer I/O
Structs§
- Chunk
Writer - A wrapper around any type that implements
ChunkMut
for improved ergonomics in generic code. - Peeker
- A peeker for reading from a buffer without advancing the original buffer’s cursor.
- Putter
- A putter for writing to a buffer without modifying the original buffer’s cursor.
- RefPeeker
- A peeker for reading from a buffer without advancing the original buffer’s cursor.
Traits§
- Chunk
- A trait for implementing custom buffers that can read and navigate through byte sequences.
- Chunk
Ext - Extension trait for
Chunk
that provides additional methods - Chunk
Mut - A trait for implementing custom buffers that can store and manipulate byte sequences.
- Chunk
MutExt - A trait that extends
ChunkMut
with additional methods. - Varint
varint
- A trait for types that can be encoded as variable-length integers (varints).