pub struct MessageFilter<Message> { /* private fields */ }
Expand description
Implementation of message filter.
Implementations§
Source§impl<Message: Hash> MessageFilter<Message>
impl<Message: Hash> MessageFilter<Message>
Sourcepub fn with_capacity(capacity: usize) -> MessageFilter<Message>
pub fn with_capacity(capacity: usize) -> MessageFilter<Message>
Constructor for capacity based MessageFilter
.
Sourcepub fn with_expiry_duration(time_to_live: Duration) -> MessageFilter<Message>
pub fn with_expiry_duration(time_to_live: Duration) -> MessageFilter<Message>
Constructor for time based MessageFilter
.
Sourcepub fn with_expiry_duration_and_capacity(
time_to_live: Duration,
capacity: usize,
) -> MessageFilter<Message>
pub fn with_expiry_duration_and_capacity( time_to_live: Duration, capacity: usize, ) -> MessageFilter<Message>
Constructor for dual-feature capacity and time based MessageFilter
.
Sourcepub fn insert(&mut self, message: &Message) -> usize
pub fn insert(&mut self, message: &Message) -> usize
Adds a message to the filter.
Removes any expired messages, then adds message
, then removes enough older messages until
the message count is at or below capacity
. If message
already exists in the filter and
is not already expired, its expiry time is updated and it is moved to the back of the FIFO
queue again.
The return value is the number of times this specific message has already been added.
Sourcepub fn remove(&mut self, message: &Message)
pub fn remove(&mut self, message: &Message)
Removes a message from the filter.
Removes any expired messages, then removes the specified message from the filter.
Sourcepub fn count(&self, message: &Message) -> usize
pub fn count(&self, message: &Message) -> usize
Returns the number of times this message has already been inserted.