1use std::ops::Deref;
2
3use crate::events::Event;
4
5pub struct EventContext<'rt, E: Event> {
6 event: &'rt E,
7 context: &'rt mut Context,
8}
9
10impl<'rt, E: Event> Deref for EventContext<'rt, E> {
11 type Target = E;
12
13 fn deref(&self) -> &'rt Self::Target {
14 self.event
15 }
16}
17
18impl<'rt, E: Event> EventContext<'rt, E> {
19 pub(crate) fn new(event: &'rt E, context: &'rt mut Context) -> Self {
20 Self { event, context }
21 }
22
23 pub fn request_shutdown(&mut self) {
24 self.context.shutdown_requested = true;
25 }
26}
27
28#[derive(Default)]
29pub(crate) struct Context {
30 pub shutdown_requested: bool,
31}