pub enum MessageFilter {
All,
MessageType(HashSet<MessageType>),
FromConnections(HashSet<ConnectionId>),
ExcludeConnections(HashSet<ConnectionId>),
Custom(Box<dyn FilterPredicate>),
}Expand description
Message filter
Variants§
All
Accept all messages
MessageType(HashSet<MessageType>)
Accept messages of specific types
FromConnections(HashSet<ConnectionId>)
Accept messages from specific connections
ExcludeConnections(HashSet<ConnectionId>)
Reject messages from specific connections
Custom(Box<dyn FilterPredicate>)
Custom filter predicate
Implementations§
Source§impl MessageFilter
impl MessageFilter
Sourcepub fn message_types(types: Vec<MessageType>) -> Self
pub fn message_types(types: Vec<MessageType>) -> Self
Create a filter for specific message types
Sourcepub fn from_connections(connections: Vec<ConnectionId>) -> Self
pub fn from_connections(connections: Vec<ConnectionId>) -> Self
Create a filter for specific connections
Sourcepub fn exclude_connections(connections: Vec<ConnectionId>) -> Self
pub fn exclude_connections(connections: Vec<ConnectionId>) -> Self
Create a filter to exclude specific connections
Sourcepub fn should_deliver(
&self,
message: &Message,
connection_id: &ConnectionId,
) -> bool
pub fn should_deliver( &self, message: &Message, connection_id: &ConnectionId, ) -> bool
Check if a message should be delivered
Auto Trait Implementations§
impl Freeze for MessageFilter
impl !RefUnwindSafe for MessageFilter
impl Send for MessageFilter
impl Sync for MessageFilter
impl Unpin for MessageFilter
impl UnsafeUnpin for MessageFilter
impl !UnwindSafe for MessageFilter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more