bytes

Zero-copy byte buffers and Buf/BufMut traits for high-performance Rust networking and IO.

Library
Cargo
v1.12.1
2,255 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
67 /100 Good
Development Activity 56
Maintenance 36
Community 76
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
90 /100 Excellent
Architecture 90
Code Quality 92
Innovation 88
Learning Curve 70

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 memory
  • BytesMut, a mutable buffer that can be split into owned, immutable Bytes views without reallocation
  • The Buf and BufMut traits for cursor-based, infallible reads and writes over arbitrary byte storage
  • no_std support and optional Serde integration behind feature flags
  • Adapters such as Chain, Take, Limit, and Reader/Writer bridges to std::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 BytesMut and splitting off completed frames to hand to the transport
  • Reading fixed-width integers and byte sequences from a stream via the Buf trait’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

Rust
65%
Apache 2.0

agentgateway

AI Development · Developer Tools · Mcp

5,071

An open source AI-native proxy that secures, observes, and governs agent-to-LLM, agent-to-tool, and agent-to-agent communication through MCP, A2A, and unified LLM routing.

View details
88
Repo Health
82
Technical
69
Dependency
Built with
Rust 65%
Go 23%
Updated 6 days ago
Dart
74%
AGPL 3.0

AppFlowy

AI Assistants · Collaboration · Productivity

76,967

The open-source AI workspace that puts your data, your rules — with local LLMs, CRDT collaboration, and full self-hosting built in.

View details
66
Repo Health
81
Technical
67
Dependency
Built with
Dart 74%
Rust 24%
Updated 1 weeks ago
Rust
54%
Other

Cap

Team Chat · Video Conferencing

22,884

Open source Loom alternative with GPU-accelerated recording, instant share links, AI summaries, and full self-hosting via Docker Compose.

View details
89
Repo Health
81
Technical
64
Dependency
Built with
Rust 54%
TypeScript 42%
Updated 5 days ago
Rust
52%
Apache 2.0

cocoindex

AI Development · Data Engineering

11,607

An incremental data indexing engine that keeps AI agent context perpetually fresh by reprocessing only what changed.

View details
87
Repo Health
85
Technical
65
Dependency
Built with
Rust 52%
Python 48%
Updated 5 days ago
Rust
80%
MIT

fabro

Developer Tools · Devops

1,658

Define AI agent workflows as code graphs, route tasks across any LLM, and intervene only where it matters.

View details
82
Repo Health
83
Technical
67
Dependency
Built with
Rust 80%
TypeScript 15%
Updated 6 days ago
TypeScript
75%
Apache 2.0

Fern

Developer Tools

3,787

Fern turns a single OpenAPI, AsyncAPI, or Protobuf definition into type-safe SDKs for nine languages and a hosted API documentation site, all from one CLI and one source of truth.

View details
90
Repo Health
86
Technical
66
Dependency
Built with
TypeScript 75%
Updated 5 days ago
Rust
99%
Other

Fluree DB

Databases

469

A temporal, verifiable graph database with git-like branching, integrated vector/text/geo search, and RDF/SPARQL/JSON-LD/openCypher support — benchmarked at 10.4x faster than the next database on the full Wikidata dump.

View details
87
Repo Health
74
Technical
65
Dependency
Built with
Rust 99%
Updated 6 days ago
Rust
94%
Apache 2.0

herdr

AI Agents · Developer Tools

41,057

A terminal-native agent multiplexer that runs Claude, Codex, Gemini, and other coding agents side by side in real, persistent panes you can detach from and reattach to from anywhere.

View details
84
Repo Health
84
Technical
72
Dependency
Built with
Rust 94%
Updated 6 days ago
Go
64%
MIT

hoop

Monitoring · Security

823

A wire-protocol gateway that enforces data masking, command blocking, approval workflows, and full session recording for engineers and AI agents accessing production infrastructure.

View details
85
Repo Health
80
Technical
64
Dependency
Built with
Go 64%
Clojure 17%
JavaScript 11%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers