spring_ai_rs/event/
mod.rs

1use std::{
2    error::Error,
3    fmt::{Display, Formatter, Result as FmtResult},
4};
5pub mod enemy;
6pub mod event_topic;
7pub mod other;
8pub mod unit;
9
10#[derive(Copy, Clone, Debug)]
11pub struct EventError {}
12
13impl Error for EventError {}
14
15impl Display for EventError {
16    fn fmt(&self, f: &mut Formatter) -> FmtResult {
17        write!(f, "{:?}", self)
18    }
19}
20
21pub fn void_to_event<'a, T>(data: *mut libc::c_void) -> Result<&'a T, Box<dyn Error>> {
22    unsafe { (data as *mut T).as_ref() }.ok_or(Box::new(EventError {}))
23}