Struct IRCMessage

Source
pub struct IRCMessage {
    pub tags: IRCTags,
    pub prefix: Option<IRCPrefix>,
    pub command: String,
    pub params: Vec<String>,
}
Expand description

A protocol-level IRC message, with arbitrary command, parameters, tags and prefix.

See RFC 2812, section 2.3.1 for the message format that this is based on. Further, this implements IRCv3 tags.

Fields§

§tags: IRCTags

A map of additional key-value tags on this message.

§prefix: Option<IRCPrefix>

The “prefix” of this message, as defined by RFC 2812. Typically specifies the sending server and/or user.

§command: String

A command like PRIVMSG or 001 (see RFC 2812 for the definition).

§params: Vec<String>

A list of parameters on this IRC message. See RFC 2812 for the definition.

Middle parameters and trailing parameters are treated the same here, and as long as there are no spaces in the last parameter, there is no way to tell if that parameter was a middle or trailing parameter when it was parsed.

Implementations§

Source§

impl IRCMessage

Source

pub fn new_simple(command: String, params: Vec<String>) -> IRCMessage

Create a new IRCMessage with just a command and parameters, similar to the irc! macro.

Source

pub fn new( tags: IRCTags, prefix: Option<IRCPrefix>, command: String, params: Vec<String>, ) -> IRCMessage

Create a new IRCMessage by specifying all fields.

Source

pub fn parse(source: &str) -> Result<IRCMessage, IRCParseError>

Parse a raw IRC wire-format message into an IRCMessage. source should be specified without trailing newline character(s).

Trait Implementations§

Source§

impl AsRawIRC for IRCMessage

Source§

fn format_as_raw_irc(&self, f: &mut Formatter<'_>) -> Result

Writes the raw IRC message to the given formatter.
Source§

fn as_raw_irc(&self) -> String
where Self: Sized,

Creates a new string with the raw IRC message. Read more
Source§

impl Clone for IRCMessage

Source§

fn clone(&self) -> IRCMessage

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for IRCMessage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for IRCMessage

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<ClearChatMessage> for IRCMessage

Source§

fn from(msg: ClearChatMessage) -> IRCMessage

Converts to this type from the input type.
Source§

impl From<ClearMsgMessage> for IRCMessage

Source§

fn from(msg: ClearMsgMessage) -> IRCMessage

Converts to this type from the input type.
Source§

impl From<GlobalUserStateMessage> for IRCMessage

Source§

fn from(msg: GlobalUserStateMessage) -> IRCMessage

Converts to this type from the input type.
Source§

impl From<JoinMessage> for IRCMessage

Source§

fn from(msg: JoinMessage) -> IRCMessage

Converts to this type from the input type.
Source§

impl From<NoticeMessage> for IRCMessage

Source§

fn from(msg: NoticeMessage) -> IRCMessage

Converts to this type from the input type.
Source§

impl From<PartMessage> for IRCMessage

Source§

fn from(msg: PartMessage) -> IRCMessage

Converts to this type from the input type.
Source§

impl From<PingMessage> for IRCMessage

Source§

fn from(msg: PingMessage) -> IRCMessage

Converts to this type from the input type.
Source§

impl From<PongMessage> for IRCMessage

Source§

fn from(msg: PongMessage) -> IRCMessage

Converts to this type from the input type.
Source§

impl From<PrivmsgMessage> for IRCMessage

Source§

fn from(msg: PrivmsgMessage) -> IRCMessage

Converts to this type from the input type.
Source§

impl From<ReconnectMessage> for IRCMessage

Source§

fn from(msg: ReconnectMessage) -> IRCMessage

Converts to this type from the input type.
Source§

impl From<RoomStateMessage> for IRCMessage

Source§

fn from(msg: RoomStateMessage) -> IRCMessage

Converts to this type from the input type.
Source§

impl From<ServerMessage> for IRCMessage

Source§

fn from(msg: ServerMessage) -> IRCMessage

Converts to this type from the input type.
Source§

impl From<ServerMessageParseError> for IRCMessage

Source§

fn from(msg: ServerMessageParseError) -> IRCMessage

Converts to this type from the input type.
Source§

impl From<UserNoticeMessage> for IRCMessage

Source§

fn from(msg: UserNoticeMessage) -> IRCMessage

Converts to this type from the input type.
Source§

impl From<UserStateMessage> for IRCMessage

Source§

fn from(msg: UserStateMessage) -> IRCMessage

Converts to this type from the input type.
Source§

impl From<WhisperMessage> for IRCMessage

Source§

fn from(msg: WhisperMessage) -> IRCMessage

Converts to this type from the input type.
Source§

impl PartialEq for IRCMessage

Source§

fn eq(&self, other: &IRCMessage) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for IRCMessage

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<IRCMessage> for ClearChatMessage

Source§

type Error = ServerMessageParseError

The type returned in the event of a conversion error.
Source§

fn try_from( source: IRCMessage, ) -> Result<ClearChatMessage, ServerMessageParseError>

Performs the conversion.
Source§

impl TryFrom<IRCMessage> for ClearMsgMessage

Source§

type Error = ServerMessageParseError

The type returned in the event of a conversion error.
Source§

fn try_from( source: IRCMessage, ) -> Result<ClearMsgMessage, ServerMessageParseError>

Performs the conversion.
Source§

impl TryFrom<IRCMessage> for GlobalUserStateMessage

Source§

type Error = ServerMessageParseError

The type returned in the event of a conversion error.
Source§

fn try_from( source: IRCMessage, ) -> Result<GlobalUserStateMessage, ServerMessageParseError>

Performs the conversion.
Source§

impl TryFrom<IRCMessage> for JoinMessage

Source§

type Error = ServerMessageParseError

The type returned in the event of a conversion error.
Source§

fn try_from(source: IRCMessage) -> Result<JoinMessage, ServerMessageParseError>

Performs the conversion.
Source§

impl TryFrom<IRCMessage> for NoticeMessage

Source§

type Error = ServerMessageParseError

The type returned in the event of a conversion error.
Source§

fn try_from( source: IRCMessage, ) -> Result<NoticeMessage, ServerMessageParseError>

Performs the conversion.
Source§

impl TryFrom<IRCMessage> for PartMessage

Source§

type Error = ServerMessageParseError

The type returned in the event of a conversion error.
Source§

fn try_from(source: IRCMessage) -> Result<PartMessage, ServerMessageParseError>

Performs the conversion.
Source§

impl TryFrom<IRCMessage> for PingMessage

Source§

type Error = ServerMessageParseError

The type returned in the event of a conversion error.
Source§

fn try_from(source: IRCMessage) -> Result<PingMessage, ServerMessageParseError>

Performs the conversion.
Source§

impl TryFrom<IRCMessage> for PongMessage

Source§

type Error = ServerMessageParseError

The type returned in the event of a conversion error.
Source§

fn try_from(source: IRCMessage) -> Result<PongMessage, ServerMessageParseError>

Performs the conversion.
Source§

impl TryFrom<IRCMessage> for PrivmsgMessage

Source§

type Error = ServerMessageParseError

The type returned in the event of a conversion error.
Source§

fn try_from( source: IRCMessage, ) -> Result<PrivmsgMessage, ServerMessageParseError>

Performs the conversion.
Source§

impl TryFrom<IRCMessage> for ReconnectMessage

Source§

type Error = ServerMessageParseError

The type returned in the event of a conversion error.
Source§

fn try_from( source: IRCMessage, ) -> Result<ReconnectMessage, ServerMessageParseError>

Performs the conversion.
Source§

impl TryFrom<IRCMessage> for RoomStateMessage

Source§

type Error = ServerMessageParseError

The type returned in the event of a conversion error.
Source§

fn try_from( source: IRCMessage, ) -> Result<RoomStateMessage, ServerMessageParseError>

Performs the conversion.
Source§

impl TryFrom<IRCMessage> for ServerMessage

Source§

type Error = ServerMessageParseError

The type returned in the event of a conversion error.
Source§

fn try_from( source: IRCMessage, ) -> Result<ServerMessage, ServerMessageParseError>

Performs the conversion.
Source§

impl TryFrom<IRCMessage> for UserNoticeMessage

Source§

type Error = ServerMessageParseError

The type returned in the event of a conversion error.
Source§

fn try_from( source: IRCMessage, ) -> Result<UserNoticeMessage, ServerMessageParseError>

Performs the conversion.
Source§

impl TryFrom<IRCMessage> for UserStateMessage

Source§

type Error = ServerMessageParseError

The type returned in the event of a conversion error.
Source§

fn try_from( source: IRCMessage, ) -> Result<UserStateMessage, ServerMessageParseError>

Performs the conversion.
Source§

impl TryFrom<IRCMessage> for WhisperMessage

Source§

type Error = ServerMessageParseError

The type returned in the event of a conversion error.
Source§

fn try_from( source: IRCMessage, ) -> Result<WhisperMessage, ServerMessageParseError>

Performs the conversion.
Source§

impl Eq for IRCMessage

Source§

impl StructuralPartialEq for IRCMessage

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T