minipool

Crates.iominipool
lib.rsminipool
version
sourcesrc
created_at2025-02-02 14:16:32.317053+00
updated_at2025-02-02 14:43:02.742549+00
descriptionLightweight, generic tokio-based pool implementation for Rust.
homepagehttps://codeberg.org/m4rc3l/minipool#readme
repositoryhttps://codeberg.org/m4rc3l/minipool.git
max_upload_size
id1539615
Cargo.toml error:TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Marcel (MarcelCoding)

documentation

README

minipool

Lightweight, generic tokio-based pool implementation for Rust.

Usage

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
}

License

Licensed under either of

at your option.

Contribution

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.

Commit count: 0

cargo fmt