| Crates.io | minipool |
| lib.rs | minipool |
| version | 0.1.2 |
| created_at | 2025-02-02 14:16:32.317053+00 |
| updated_at | 2025-05-13 20:02:18.035809+00 |
| description | Lightweight, generic tokio-based pool implementation for Rust. |
| homepage | https://codeberg.org/m4rc3l/minipool#readme |
| repository | https://codeberg.org/m4rc3l/minipool.git |
| max_upload_size | |
| id | 1539615 |
| size | 26,854 |
Lightweight, generic tokio-based pool implementation for Rust.
use std::ops::{Deref, DerefMut};
use minipool::{Pool, PoolEntry};
const BUF_SIZE: usize = 9000;
struct Buf(Box<[u8; BUF_SIZE]>);
impl PoolEntry for Buf {
fn is_closed(&self) -> bool {
false
}
}
// allows to call methods from `&[u8]` directly on `Buf`
impl Deref for Buf {
type Target = Box<[u8; BUF_SIZE]>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
// allows to call methods from `&mut [u8]` directly on `Buf`
impl DerefMut for Buf {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
async fn run() {
let pool = Pool::default();
pool.push(Buf(Box::new([0u8; BUF_SIZE])));
{
let buf = pool.acquire().await;
// do things with `buf`
}
// the buffer got reinserted into the pool
}
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.