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§
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
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 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