bytes
Zero-copy byte buffers and Buf/BufMut traits for high-performance Rust networking and IO.
Repository Health
Technical Analysis
Bytes is a foundational Rust utility crate from the Tokio project for storing and operating on contiguous slices of memory. Its core Bytes type is a cheaply cloneable, sliceable buffer that enables zero-copy network programming: multiple handles can point to the same underlying, reference-counted memory, each with its own view, so passing buffers around never copies the payload.
Alongside the owned Bytes and mutable BytesMut containers, the crate provides the Buf and BufMut traits, which offer cursor-based, infallible read and write access over any byte storage (contiguous or chunked). It is no_std-compatible and sits at the base of much of the Rust async and networking ecosystem, including Hyper, Tonic, and Tokio itself.
What You Get
Bytes, a cheaply cloneable and sliceable owned buffer backed by reference-counted shared memoryBytesMut, a mutable buffer that can be split into owned, immutableBytesviews without reallocation- The
BufandBufMuttraits for cursor-based, infallible reads and writes over arbitrary byte storage no_stdsupport and optional Serde integration behind feature flags- Adapters such as
Chain,Take,Limit, andReader/Writerbridges tostd::io
Common Use Cases
- Parsing and framing network protocols where a received buffer is sliced into headers and payloads without copying
- Building async servers and clients on Tokio, Hyper, or Tonic that pass shared buffers between layers
- Accumulating outgoing data in a
BytesMutand splitting off completed frames to hand to the transport - Reading fixed-width integers and byte sequences from a stream via the
Buftrait’s typed getters
Under The Hood
Architecture - The crate is organized around two concrete containers in src/bytes.rs and src/bytes_mut.rs and a trait layer in src/buf/. Bytes is a 4-usize struct holding a data pointer, a length, and a pointer to shared state plus a Vtable of function pointers (clone, to_vec, to_mut, is_unique, drop); this dynamic-dispatch design lets one type transparently back static memory, Vec<u8>, or Arc-shared storage while keeping slicing and cloning cheap. BytesMut manages a growable allocation with an atomic reference count so that split/split_to can hand out disjoint owned views. The buf module layers Buf/BufMut traits over any storage and ships adapters (Chain, Take, Limit, Reader, Writer).
Tech Stack - Pure Rust targeting edition 2021 with an MSRV of 1.57 and a #![no_std] core that pulls in alloc. It has zero required dependencies; serde (data formats) and portable-atomic (atomic CAS on constrained targets) are optional feature-gated deps, and loom is used only for concurrency testing. The standard library is opt-in via the default std feature.
Code Quality - Quality is exceptional: the tests/ directory holds roughly 200 test functions across 12 files, including dedicated allocator-behavior tests (test_bytes_odd_alloc.rs, test_bytes_vec_alloc.rs) and loom-based concurrency model checking for the atomic reference-counting paths. Unsafe pointer code is carefully commented, bounds checking is centralized in a range helper, and there is a Miri-checked CI pipeline. Naming is consistent and the public surface is thoroughly documented with runnable doc examples.
API Design - The public API is small, ergonomic, and discoverable: two container types plus two traits cover the whole surface. Typed accessors (get_u16, put_u32, try_get_*) make protocol code read cleanly, From impls accept &[u8], Vec<u8>, and &'static str, and getting started requires nothing more than use bytes::{Bytes, BytesMut, Buf, BufMut}. Documentation on docs.rs is comprehensive with feature-gate annotations.
Used by 46 apps in this directory
Svix
Automation · Developer Tools
Open source, self-hostable webhook infrastructure that handles delivery, retries, HMAC signing, and multi-tenant event management so you never have to build a webhooks system from scratch.
Temps
Analytics · Devops · Monitoring
A self-hosted Rust PaaS that replaces Vercel, Sentry, PostHog, Pingdom, Resend, and E2B with one binary — plus 440+ CLI operations agents like Claude Code can drive directly.
TensorZero
Ab Testing Experimentation · AI Development · Monitoring
TensorZero unifies the LLM gateway, observability, evaluation, optimization, and experimentation stack behind a single OpenAI-compatible API, built in Rust for sub-millisecond p99 latency.
Trieve
AI Development · Developer Tools · Search
All-in-one self-hostable platform for hybrid search, RAG, recommendations, and analytics built on Rust and Qdrant.
Vaultwarden
Password Manager · Security
Unofficial Bitwarden-compatible server in Rust — run the full Bitwarden ecosystem on a Raspberry Pi using every official client you already have, without the multi-container overhead.
Vibe Kanban
AI Agents · AI Code Assistants · Project Management
A kanban board for planning work and dispatching Claude Code, Codex, Gemini CLI, and eight other coding agents into isolated git worktrees, then reviewing and merging their diffs from one UI.
Void
AI Code Assistants · Automation · Code Editors
Open-source AI code editor with direct LLM integration and data privacy
Volga
Data Engineering
A Rust-based real-time data processing engine for AI/ML feature computation, built on Apache DataFusion and Arrow — positioned as an alternative to Flink, Spark, Chronon, and OpenMLDB with unified streaming, batch, and request-time execution.
WrenAI
AI Agents · Analytics · Data Engineering
Open-source GenBI engine that lets AI agents turn natural-language questions into governed SQL, charts, and shareable dashboards across 20+ data sources — no vendor lock-in, no black-box prompts.