[][src]Trait twitchchat::Validator

pub trait Validator {
    fn parse_tags(&self) -> TagIndices;
fn expect_command(&self, cmd: &str) -> Result<(), MessageError>;
fn expect_nick(&self) -> Result<MaybeOwnedIndex, MessageError>;
fn expect_arg(&self, nth: usize) -> Result<&str, MessageError>;
fn expect_arg_index(
        &self,
        nth: usize
    ) -> Result<MaybeOwnedIndex, MessageError>;
fn expect_data(&self) -> Result<&str, MessageError>;
fn expect_data_index(&self) -> Result<MaybeOwnedIndex, MessageError>; }

This trait is provided as an easy way of defining your own custom events.

Required methods

fn parse_tags(&self) -> TagIndices

Pre-compute the tag indices

fn expect_command(&self, cmd: &str) -> Result<(), MessageError>

You expect a command matching 'cmd'. See the constants in IrcMessage

fn expect_nick(&self) -> Result<MaybeOwnedIndex, MessageError>

You expect a user nickname to be attached. This returns the MaybeOwnedIndex of it

fn expect_arg(&self, nth: usize) -> Result<&str, MessageError>

You expect an argumnet at position 'nth' (0-based). This returns the &str of it.

fn expect_arg_index(&self, nth: usize) -> Result<MaybeOwnedIndex, MessageError>

You expect an argumnet at position 'nth' (0-based). This returns the MaybeOwnedIndex of it.

fn expect_data(&self) -> Result<&str, MessageError>

You expect data to be attached to the message. This returns the &str of it.

fn expect_data_index(&self) -> Result<MaybeOwnedIndex, MessageError>

You expect data to be attached to the message. This returns the MaybeOwnedIndex of it.

Loading content...

Implementors

Loading content...