rbuckets 0.1.0

A Rust library for managing buckets of items with various operations.
Documentation
  • Coverage
  • 95.24%
    20 out of 21 items documented0 out of 15 items with examples
  • Size
  • Source code size: 13.74 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.58 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • gntem/rbuckets
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • gntem

rbuckets

A generic Rust bucket structure with history and item limits.

Features

  • Store items of any type (e.g., strings, numbers)
  • Enforce limits on the number of items and history entries
  • Undo, clear, and poll items with epoch tracking

Example Usage

use rbuckets::RBucket;

fn main() {
    // Create a new bucket for fruit, with default limits
    let mut fruit_bucket = RBucket::new("fruit".to_string(), None, None);

    // Add apples and bananas
    fruit_bucket.add_item("apple");
    fruit_bucket.add_item("banana");

    // Add multiple items at once
    fruit_bucket.add_items(vec!["apple", "banana"]);

    // Iterate over items
    for fruit in fruit_bucket.iter() {
        println!("Fruit: {}", fruit);
    }

    // Poll (remove) the first item
    if let Some(fruit) = fruit_bucket.poll() {
        println!("Polled: {}", fruit);
    }

    // Undo the last poll
    fruit_bucket.undo();
}

License

MIT