abin 0.1.6

A library for working with binaries and strings. The library tries to avoid heap-allocations / memory-copy whenever possible by automatically choosing a reasonable strategy: stack for small binaries; static-lifetime-binary or reference-counting.
Documentation
use crate::{AnyRc, AnyRcConfigForNonSync, AnyRcImpl, Bin};

/// A reference-counted binary. Note: The reference counter is not synchronized, so this
/// is not `Send + Sync` but there's less overhead. Cloning is cheap. See `AnyRc`.
pub struct RcBin;

impl AnyRc for RcBin {
    type T = Bin;

    #[inline]
    fn copy_from_slice(slice: &[u8]) -> Self::T {
        AnyRcImpl::<AnyRcConfigForNonSync>::copy_from_slice(slice)
    }

    #[inline]
    fn from_iter(iter: impl IntoIterator<Item = u8>) -> Self::T {
        AnyRcImpl::<AnyRcConfigForNonSync>::from_iter(iter)
    }

    #[inline]
    fn from_vec(vec: Vec<u8>) -> Self::T {
        AnyRcImpl::<AnyRcConfigForNonSync>::from_vec(vec)
    }

    #[inline]
    fn overhead_bytes() -> usize {
        AnyRcImpl::<AnyRcConfigForNonSync>::overhead_bytes()
    }
}