Struct dazeus::Event
[−]
[src]
pub struct Event { pub event: EventType, pub params: Vec<String>, }
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 | The type of event that was received. |
params | The parameters attached to the event. |
Methods
impl Event
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() ))
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.
fn param<'a>(&'a self, idx: usize) -> &'a str
Retrieve a parameter from the list of parameters contained in the event.
fn len(&self) -> usize
Retrieve the number of parameters for the event.