[][src]Struct irc_rust::message::Message

pub struct Message { /* fields omitted */ }

A simple irc message containing tags, prefix, command, parameters and a trailing parameter.

Examples

use irc_rust::message::Message;

let message = Message::new("@key1=value1;key2=value2 :name!user@host CMD param1 param2 :trailing");

assert_eq!(message.to_string(), "@key1=value1;key2=value2 :name!user@host CMD param1 param2 :trailing");
use irc_rust::message::Message;
use irc_rust::prefix::Prefix;

let message = Message::builder()
        .tag("key1", "value1")
        .tag("key2", "value2")
        .prefix(Prefix::builder("name")
            .user("user")
            .host("host")
        )
        .command("CMD")
        .param("param1").param("param2")
        .trailing("trailing")
        .build();

match message {
    Ok(mssg) => {
        let tags = mssg.tags().unwrap();
        println!("key1={}", tags["key1"]) // Prints 'key1=value1'
    }
    Err(e) => println!("message building failed: {}", e)
}

Methods

impl Message[src]

pub fn new(value: &str) -> Message[src]

Create a new Message from the given string. Expects the string to be in a valid irc format.

pub fn builder() -> MessageBuilder<'static>[src]

Creates a message builder as alternative to building an irc string before creating the message.

pub fn tags(&self) -> Option<Tags>[src]

Returns tags if any are present.

pub fn prefix(&self) -> Option<Prefix>[src]

Returns the Prefix if present.

pub fn command(&self) -> &str[src]

Returns the command the message represents.

pub fn params(&self) -> Option<Params>[src]

Returns the params if any are present.

Trait Implementations

impl ToString for Message[src]

Auto Trait Implementations

impl RefUnwindSafe for Message

impl Send for Message

impl Sync for Message

impl Unpin for Message

impl UnwindSafe for Message

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.