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:

  1. Using the params field directly.
  2. Using the param() method with an index which will return a string slice.
  3. 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.

Trait Implementations

impl<'b> Index<usize> for Event

type Output = str

fn index<'a>(&'a self, index: usize) -> &'a str

Derived Implementations

impl PartialEq for Event

fn eq(&self, __arg_0: &Event) -> bool

fn ne(&self, __arg_0: &Event) -> bool

impl Clone for Event

fn clone(&self) -> Event

fn clone_from(&mut self, source: &Self)

impl Debug for Event

fn fmt(&self, __arg_0: &mut Formatter) -> Result