Struct irc::proto::message::Message [] [src]

pub struct Message {
    pub tags: Option<Vec<Tag>>,
    pub prefix: Option<String>,
    pub command: Command,
}

A data structure representing an IRC message according to the protocol specification. It consists of a collection of IRCv3 tags, a prefix (describing the source of the message), and the protocol command. If the command is unknown, it is treated as a special raw command that consists of a collection of arguments and the special suffix argument. Otherwise, the command is parsed into a more useful form as described in Command.

Fields

Message tags as defined by IRCv3.2. These tags are used to add extended information to the given message, and are commonly used in IRCv3 extensions to the IRC protocol.

The message prefix (or source) as defined by RFC 2812.

The IRC command, parsed according to the known specifications. The command itself and its arguments (including the special suffix argument) are captured in this component.

Methods

impl Message
[src]

[src]

Creates a new message from the given components.

Example

let message = Message::new(
    Some("nickname!username@hostname"), "JOIN", vec!["#channel"], None
).unwrap();

[src]

Creates a new IRCv3.2 message from the given components, including message tags. These tags are used to add extended information to the given message, and are commonly used in IRCv3 extensions to the IRC protocol.

[src]

Gets the nickname of the message source, if it exists.

Example

let message = Message::new(
    Some("nickname!username@hostname"), "JOIN", vec!["#channel"], None
).unwrap();
assert_eq!(message.source_nickname(), Some("nickname"));

[src]

Gets the likely intended place to respond to this message. If the type of the message is a PRIVMSG or NOTICE and the message is sent to a channel, the result will be that channel. In all other cases, this will call source_nickname.

Example

let msg1 = Message::new(
    Some("ada"), "PRIVMSG", vec!["#channel"], Some("Hi, everyone!")
).unwrap();
assert_eq!(msg1.response_target(), Some("#channel"));
let msg2 = Message::new(
    Some("ada"), "PRIVMSG", vec!["betsy"], Some("betsy: hi")
).unwrap();
assert_eq!(msg2.response_target(), Some("ada"));

[src]

Converts a Message into a String according to the IRC protocol.

Example

let msg = Message::new(
    Some("ada"), "PRIVMSG", vec!["#channel"], Some("Hi, everyone!")
).unwrap();
assert_eq!(msg.to_string(), ":ada PRIVMSG #channel :Hi, everyone!\r\n");

Trait Implementations

impl Clone for Message
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl PartialEq for Message
[src]

[src]

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

[src]

This method tests for !=.

impl Debug for Message
[src]

[src]

Formats the value using the given formatter. Read more

impl From<Command> for Message
[src]

[src]

Performs the conversion.

impl FromStr for Message
[src]

The associated error which can be returned from parsing.

[src]

Parses a string s to return a value of this type. Read more

impl<'a> From<&'a str> for Message
[src]

[src]

Performs the conversion.

impl Display for Message
[src]

[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for Message

impl Sync for Message