Crate message_filter [] [src]

Message Filter

A size or time based message filter that takes any generic type as a key and will drop keys after a time period, or once a maximum number of messages is reached (LRU Cache pattern). The filter currently only allows adding messages; a delete function will be provided at a later stage.

This library can be used by network based systems to filter previously seen messages.


use ::message_filter::MessageFilter;

// Construct a `MessageFilter` of `u8`s, limited by message count
let max_count = 10;
let message_filter = MessageFilter::<u8>::with_capacity(max_count);

// Construct a `MessageFilter` of `String`s, limited by expiry time
let time_to_live = ::std::time::Duration::from_millis(100);
let message_filter = MessageFilter::<String>::with_expiry_duration(time_to_live);

// Construct a `MessageFilter` of `Vec<u8>`s, limited by message count and expiry time
let message_filter = MessageFilter::<Vec<u8>>::with_expiry_duration_and_capacity(time_to_live,



Implementation of message filter.