Enum twitch_irc::message::IRCPrefix  
source · [−]pub enum IRCPrefix {
    HostOnly {
        host: String,
    },
    Full {
        nick: String,
        user: Option<String>,
        host: Option<String>,
    },
}Expand description
A “prefix” part of an IRC message, as defined by RFC 2812:
<prefix>     ::= <servername> | <nick> [ '!' <user> ] [ '@' <host> ]
<servername> ::= <host>
<nick>       ::= <letter> { <letter> | <number> | <special> }
<user>       ::= <nonwhite> { <nonwhite> }
<host>       ::= see RFC 952 [DNS:4] for details on allowed hostnames
<letter>     ::= 'a' ... 'z' | 'A' ... 'Z'
<number>     ::= '0' ... '9'
<special>    ::= '-' | '[' | ']' | '\' | '`' | '^' | '{' | '}'
<nonwhite>   ::= <any 8bit code except SPACE (0x20), NUL (0x0), CR
                  (0xd), and LF (0xa)>Examples
use twitch_irc::message::IRCPrefix;
use twitch_irc::message::AsRawIRC;
let prefix = IRCPrefix::Full {
    nick: "a_nick".to_owned(),
    user: Some("a_user".to_owned()),
    host: Some("a_host.com".to_owned())
};
assert_eq!(prefix.as_raw_irc(), "a_nick!a_user@a_host.com");use twitch_irc::message::IRCPrefix;
use twitch_irc::message::AsRawIRC;
let prefix = IRCPrefix::Full {
    nick: "a_nick".to_owned(),
    user: None,
    host: Some("a_host.com".to_owned())
};
assert_eq!(prefix.as_raw_irc(), "a_nick@a_host.com");use twitch_irc::message::IRCPrefix;
use twitch_irc::message::AsRawIRC;
let prefix = IRCPrefix::HostOnly {
    host: "a_host.com".to_owned()
};
assert_eq!(prefix.as_raw_irc(), "a_host.com");Variants
HostOnly
Fields
host: Stringhost part of the prefix
The prefix specifies only a sending server/hostname.
Note that the spec also allows a very similar format where only a sending nickname is
specified. However that type of format plays no role on Twitch, and is practically impossible
to reliably tell apart from host-only prefix messages. For this reason, a prefix without
a @ character is always assumed to be purely a host-only prefix, and not a nickname-only prefix.
Full
Fields
nick: Stringnick part of the prefix
The prefix variant specifies a nickname, and optionally also a username and optionally a hostname. See above for the RFC definition.
Implementations
sourceimpl IRCPrefix
 
impl IRCPrefix
sourcepub fn parse(source: &str) -> IRCPrefix
 
pub fn parse(source: &str) -> IRCPrefix
Parse the IRCPrefix from the given string slice. source should be specified without
the leading : that precedes in full IRC messages.
Examples
use twitch_irc::message::IRCPrefix;
let prefix = IRCPrefix::parse("a_nick!a_user@a_host.com");
assert_eq!(prefix, IRCPrefix::Full {
    nick: "a_nick".to_owned(),
    user: Some("a_user".to_owned()),
    host: Some("a_host.com".to_owned())
})use twitch_irc::message::IRCPrefix;
let prefix = IRCPrefix::parse("a_host.com");
assert_eq!(prefix, IRCPrefix::HostOnly {
    host: "a_host.com".to_owned()
})Trait Implementations
sourceimpl<'de> Deserialize<'de> for IRCPrefix
 
impl<'de> Deserialize<'de> for IRCPrefix
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
    __D: Deserializer<'de>,
 
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
    __D: Deserializer<'de>,
impl Eq for IRCPrefix
impl StructuralEq for IRCPrefix
impl StructuralPartialEq for IRCPrefix
Auto Trait Implementations
impl RefUnwindSafe for IRCPrefix
impl Send for IRCPrefix
impl Sync for IRCPrefix
impl Unpin for IRCPrefix
impl UnwindSafe for IRCPrefix
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
sourceimpl<Q, K> Equivalent<K> for Qwhere
    Q: Eq + ?Sized,
    K: Borrow<Q> + ?Sized,
 
impl<Q, K> Equivalent<K> for Qwhere
    Q: Eq + ?Sized,
    K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
 
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.