Struct message_filter::MessageFilter [] [src]

pub struct MessageFilter<Message> {
    // some fields omitted
}

Implementation of message filter.

Methods

impl<Message: Hash> MessageFilter<Message>
[src]

fn with_capacity(capacity: usize) -> MessageFilter<Message>

Constructor for capacity based MessageFilter.

fn with_expiry_duration(time_to_live: Duration) -> MessageFilter<Message>

Constructor for time based MessageFilter.

fn with_expiry_duration_and_capacity(time_to_live: Duration, capacity: usize) -> MessageFilter<Message>

Constructor for dual-feature capacity and time based MessageFilter.

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.

fn remove(&mut self, message: &Message)

Removes a message from the filter.

Removes any expired messages, then removes the specified message from the filter.

fn count(&self, message: &Message) -> usize

Returns the number of times this message has already been inserted.

fn contains(&mut self, message: &Message) -> bool

Removes any expired messages, then returns whether message exists in the filter or not.

fn len(&self) -> usize

Returns the size of the filter, i.e. the number of added messages.

fn is_empty(&self) -> bool

Returns whether there are no entries in the filter.