15 releases (7 breaking)

0.9.1 Nov 23, 2025
0.8.0 Sep 24, 2025
0.7.0 May 9, 2025
0.6.1 Mar 27, 2025
0.2.0 Aug 25, 2024

#153 in Data structures

Download history 6366/week @ 2025-08-12 5992/week @ 2025-08-19 4619/week @ 2025-08-26 5049/week @ 2025-09-02 6216/week @ 2025-09-09 5743/week @ 2025-09-16 5749/week @ 2025-09-23 4931/week @ 2025-09-30 4621/week @ 2025-10-07 6106/week @ 2025-10-14 5513/week @ 2025-10-21 6805/week @ 2025-10-28 7106/week @ 2025-11-04 5746/week @ 2025-11-11 6469/week @ 2025-11-18 3886/week @ 2025-11-25

24,396 downloads per month
Used in 53 crates (7 directly)

MIT/Apache

55KB
1.5K SLoC

byteview

CI CI docs.rs Crates.io MSRV

An immutable byte slice that may be inlined, and can be partially cloned without heap allocation.

Think of it as a specialized Arc<[u8]> that can be inlined (skip allocation for small values) and no weak count.

Memory layout

byteview was originally designed to speed up deserialization in lsm-tree, allow inlining of small values and reduce memory usage compared to Arc'd slices. Values with a known length can be constructed 2-2.5x faster than using Arc<[u8]>:

Constructor benchmark

Sponsors

Orbitinghail

Memory usage

Allocating 200M "" (len=0) strings:

Struct Memory Usage
Arc<[u8]> 9.6 GB
tokio::Bytes 6.4 GB
ByteView 4.8 GB

Allocating 200M "helloworld" (len=10) strings:

Struct Memory Usage
Arc<[u8]> 12.8 GB
tokio::Bytes 12.8 GB
ByteView 4.8 GB

Allocating 100M "helloworldhelloworld" (len=20) strings:

Struct Memory Usage
Arc<[u8]> 6.4 GB
tokio::Bytes 6.4 GB
ByteView 2.4 GB

Allocating 50M "helloworldhelloworldhelloworldhelloworld" (len=30) strings:

Struct Memory Usage
Arc<[u8]> 4.0 GB
tokio::Bytes 4.0 GB
ByteView 3.6 GB

Allocating 500k "helloworld".repeat(1000) (len=10'000) strings:

Struct Memory Usage
Arc<[u8]> 5 GB
tokio::Bytes 5 GB
ByteView 5 GB

Run fuzz tests

cargo +nightly fuzz run fuzz_target_1

Dependencies

~165KB