pub struct Event {
pub event: EventType,
pub params: Vec<String>,
}Expand description
An event received from the DaZeus server.
You can retrieve the parameters from the event using one of three different methods:
- Using the params field directly.
- Using the
param()method with an index which will return a string slice. - Using indexing on the event struct itself, i.e.
event[0]to receive the first parameter.
The prefered method is the last one.
Fields§
§event: EventTypeThe type of event that was received.
params: Vec<String>The parameters attached to the event.
Implementations§
Source§impl Event
impl Event
Sourcepub fn new(event: EventType, params: Vec<String>) -> Event
pub fn new(event: EventType, params: Vec<String>) -> Event
Create a new event based on the basic properties of an event.
Allows creation of events for testing purposes. Also used internally for constructing events based on parsed Json objects.
§Example
Event::new(EventType::PrivMsg, vec!(
"network".to_string(),
"sender".to_string(),
"receiver".to_string(),
"message".to_string()
))Sourcepub fn from_json(data: &Json) -> Result<Event, InvalidJsonError>
pub fn from_json(data: &Json) -> Result<Event, InvalidJsonError>
Create a new event based on a Json data object.
Typically this method will be called by the bindings itself to create an event instance from some received json blob from the core.
Trait Implementations§
impl StructuralPartialEq for Event
Auto Trait Implementations§
impl Freeze for Event
impl RefUnwindSafe for Event
impl Send for Event
impl Sync for Event
impl Unpin for Event
impl UnwindSafe for Event
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