#[non_exhaustive]pub enum Priority {
Lowest = 0,
Low = 25,
Normal = 50,
High = 75,
Highest = 100,
Critical = 125,
}Expand description
Priority levels for event listeners
Listeners with higher priority are executed first. This allows for controlling the execution order of event handlers.
§Example
use mod_events::{EventDispatcher, Priority, Event};
#[derive(Debug, Clone)]
struct MyEvent {
message: String,
}
impl Event for MyEvent {
fn as_any(&self) -> &dyn std::any::Any {
self
}
}
let dispatcher = EventDispatcher::new();
// This will execute first
dispatcher.subscribe_with_priority(|event: &MyEvent| {
println!("High priority handler");
Ok(())
}, Priority::High);
// This will execute second
dispatcher.subscribe_with_priority(|event: &MyEvent| {
println!("Normal priority handler");
Ok(())
}, Priority::Normal);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Lowest = 0
Lowest priority (0)
Low = 25
Low priority (25)
Normal = 50
Normal priority (50) - default
High = 75
High priority (75)
Highest = 100
Highest priority (100)
Critical = 125
Critical priority (125) - use sparingly
Implementations§
Trait Implementations§
Source§impl Ord for Priority
impl Ord for Priority
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Priority
impl PartialOrd for Priority
impl Copy for Priority
impl Eq for Priority
impl StructuralPartialEq for Priority
Auto Trait Implementations§
impl Freeze for Priority
impl RefUnwindSafe for Priority
impl Send for Priority
impl Sync for Priority
impl Unpin for Priority
impl UnsafeUnpin for Priority
impl UnwindSafe for Priority
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