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: EventType

The type of event that was received.

params: Vec<String>

The parameters attached to the event.

Methods

impl Event
[src]

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<EventInvalidJsonError>

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 PartialEq for Event
[src]

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

This method tests for self and other values to be equal, and is used by ==. Read more

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

This method tests for !=.

impl Clone for Event
[src]

fn clone(&self) -> Event

Returns a copy of the value. Read more

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

Performs copy-assignment from source. Read more

impl Debug for Event
[src]

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

Formats the value using the given formatter.

impl<'b> Index<usize> for Event
[src]

type Output = str

The returned type after indexing

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

The method for the indexing (Foo[Bar]) operation