chunkrs 0.9.0

A high-performance, deterministic, flexible and portable zero-copy streaming Content-Defined Chunking (CDC) and hashing infrastructure library. Bytes in → Chunks & hashes out
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Internal utility functions and helpers.
//!
//! This module contains small helper functions used throughout the crate.
//! It is an implementation detail and not part of the public API.

use bytes::Bytes;

/// Combines two byte slices into a new Bytes object.
///
/// This is used when pending bytes need to be combined with new data
/// to form a complete chunk.
pub fn combine_bytes(a: &Bytes, b: &[u8]) -> Bytes {
    let mut combined = Vec::with_capacity(a.len() + b.len());
    combined.extend_from_slice(a);
    combined.extend_from_slice(b);
    Bytes::from(combined)
}