delay_map

Crates.iodelay_map
lib.rsdelay_map
version0.4.1
created_at2022-01-31 01:52:40.637119+00
updated_at2025-03-17 22:52:59.384066+00
descriptionHashMap collections whose entries expire after a given time
homepage
repositoryhttps://github.com/agemanning/delay_map
max_upload_size
id524300
size45,269
Age Manning (AgeManning)

documentation

README

delay_map

Build Status Doc Status Crates
Status

Documentation at docs.rs

Overview

This crate contains two data structures, [HashSetDelay] and [HashMapDelay]. These behave like the standard library HashSet and HashMaps with the added feature that entries inserted into the mappings expire after a fixed period of time.

Usage

Creating a map

    use delay_map::HashMapDelay;
    use futures::prelude::*;

    // Set a default timeout for entries
    let mut delay_map = HashMapDelay::new(std::time::Duration::from_secs(1));


    tokio_test::block_on(async {

    delay_map.insert(1, "entry_1");
    delay_map.insert(2, "entry_2");
    
    if let Some(Ok((key, value))) = delay_map.next().await {
        println!("Entry 1: {}, {}", key, value);  
    }

    if let Some(Ok((key, value))) = delay_map.next().await {
        println!("Entry 2: {}, {}", key,value);  
    }
    });
Commit count: 35

cargo fmt