Struct MessageFilter

Source
pub struct MessageFilter<Message> { /* private fields */ }
Expand description

Implementation of message filter.

Implementations§

Source§

impl<Message: Hash> MessageFilter<Message>

Source

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

Constructor for capacity based MessageFilter.

Source

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

Constructor for time based MessageFilter.

Source

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

Constructor for dual-feature capacity and time based MessageFilter.

Source

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.

Source

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.

Source

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

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

Source

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

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

Source

pub fn len(&self) -> usize

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

Source

pub fn clear(&mut self)

Clears the filter, removing all entries.

Source

pub fn is_empty(&self) -> bool

Returns whether there are no entries in the filter.

Auto Trait Implementations§

§

impl<Message> Freeze for MessageFilter<Message>

§

impl<Message> RefUnwindSafe for MessageFilter<Message>
where Message: RefUnwindSafe,

§

impl<Message> Send for MessageFilter<Message>
where Message: Send,

§

impl<Message> Sync for MessageFilter<Message>
where Message: Sync,

§

impl<Message> Unpin for MessageFilter<Message>
where Message: Unpin,

§

impl<Message> UnwindSafe for MessageFilter<Message>
where Message: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.