1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
use std::{ any::TypeId, fmt::{Debug, Formatter, Result}, }; use crate::packet_reader::PacketReader; use super::event_type::EventType; /// Handles the creation of new Events pub trait EventBuilder<T: EventType> { /// Gets the TypeId of the Event it is able to build fn get_type_id(&self) -> TypeId; /// Creates a new Event fn build(&self, reader: &mut PacketReader) -> T; } impl<T: EventType> Debug for Box<dyn EventBuilder<T>> { fn fmt(&self, f: &mut Formatter<'_>) -> Result { f.write_str("Boxed EventBuilder") } }