simd-brotli 9.0.1

A brotli compressor and decompressor with an interface avoiding the rust stdlib, so it suits embedded devices and kernels. A fork of `brotli` whose encoder hot paths are vectorized with `fearless_simd`, giving runtime-dispatched SIMD on stable Rust with no unsafe code. It is designed with a pluggable allocator so that the standard lib's allocator may be employed. The default build also includes a stdlib allocator and stream interface. Disable this with --features=no-stdlib. All included code is safe.
Documentation
use alloc::{Allocator, SliceWrapper, SliceWrapperMut};

use brotli_decompressor::ffi::alloc_util::SubclassableAllocator;

use crate::enc::BrotliAlloc;

pub struct BrotliSubclassableAllocator(SubclassableAllocator);

impl BrotliSubclassableAllocator {
    pub fn new(s: SubclassableAllocator) -> BrotliSubclassableAllocator {
        BrotliSubclassableAllocator(s)
    }
}

#[derive(Default)]
pub struct SendableMemoryBlock<T: Clone + Default>(
    <SubclassableAllocator as Allocator<T>>::AllocatedMemory,
);
impl<T: Clone + Default> SliceWrapperMut<T> for SendableMemoryBlock<T> {
    fn slice_mut(&mut self) -> &mut [T] {
        self.0.slice_mut()
    }
}
impl<T: Clone + Default> SliceWrapper<T> for SendableMemoryBlock<T> {
    fn slice(&self) -> &[T] {
        self.0.slice()
    }
}
impl<T: Clone + Default> Allocator<T> for BrotliSubclassableAllocator {
    type AllocatedMemory = SendableMemoryBlock<T>;
    fn alloc_cell(&mut self, s: usize) -> Self::AllocatedMemory {
        SendableMemoryBlock(self.0.alloc_cell(s))
    }
    fn free_cell(&mut self, data: Self::AllocatedMemory) {
        self.0.free_cell(data.0)
    }
}

impl BrotliAlloc for BrotliSubclassableAllocator {}
unsafe impl Send for BrotliSubclassableAllocator {}

unsafe impl<T: Clone + Default> Send for SendableMemoryBlock<T> {}

#[cfg(not(feature = "std"))]
#[cfg(feature = "no-stdlib-ffi-binding")]
#[panic_handler]
extern "C" fn panic_impl(_: &::core::panic::PanicInfo) -> ! {
    loop {}
}

#[cfg(not(feature = "std"))]
#[cfg(feature = "no-stdlib-ffi-binding")]
#[lang = "eh_personality"]
extern "C" fn eh_personality() {}