santh-bufpool 0.1.0

Typed buffer recycling with fixed size classes and lock-free checkout/return
Documentation
//! Typed buffer recycling with fixed size classes and lock-free queues.
//!
//! The pool keeps four reusable buffer classes: 4 KiB, 64 KiB, 256 KiB, and
//! 1 MiB. Requests are rounded up to the smallest fitting class. If a class is
//! exhausted, the pool falls back to a one-off allocation without blocking.
//!
//! # Examples
//!
//! ```rust
//! use santh_bufpool::{BufferPool, PoolConfig};
//!
//! let pool = BufferPool::new(PoolConfig {
//!     four_kib_count: 2,
//!     ..PoolConfig::default()
//! });
//! let mut buffer = pool.checkout(128).unwrap();
//! buffer[0] = 42;
//! assert_eq!(buffer.len(), 128);
//! assert!(buffer.capacity() >= 128);
//! ```

#![warn(missing_docs, clippy::pedantic)]
#![cfg_attr(
    not(test),
    deny(
        clippy::unwrap_used,
        clippy::expect_used,
        clippy::todo,
        clippy::unimplemented,
        clippy::panic
    )
)]
#![allow(clippy::module_name_repetitions, clippy::must_use_candidate)]

mod buffer;
mod config;
/// Error types and constants for bufpool.
pub mod error;
mod pool;
mod size_class;
mod stats;
mod tls;

pub use buffer::{FrozenBuffer, PoolBuffer};
pub use config::PoolConfig;
pub use error::{Error, Result};
pub use pool::BufferPool;
pub use stats::{PoolStats, PoolStatsSnapshot};

#[doc(hidden)]
pub use tls::clear_tls_cache as clear_tls_cache_for_test;